F - Spotlights CodeForces - 738B

Theater stage is a rectangular field of size n × m. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cell or not.

You are to place a spotlight on the stage in some good position. The spotlight will project light in one of the four directions (if you look at the stage from above) — left, right, up or down. Thus, the spotlight's position is a cell it is placed to and a direction it shines.

A position is good if two conditions hold:

  • there is no actor in the cell the spotlight is placed to;
  • there is at least one actor in the direction the spotlight projects.

Count the number of good positions for placing the spotlight. Two positions of spotlight are considered to be different if the location cells or projection direction differ.

Input

The first line contains two positive integers n and m (1 ≤ n, m ≤ 1000) — the number of rows and the number of columns in the plan.

The next n lines contain m integers, 0 or 1 each — the description of the plan. Integer 1, means there will be an actor in the corresponding cell, while 0 means the cell will remain empty. It is guaranteed that there is at least one actor in the plan.

Output

Print one integer — the number of good positions for placing the spotlight.

Examples
Input
2 4
0 1 0 0
1 0 1 0
Output
9
Input
4 4
0 0 0 0
1 0 0 1
0 1 1 0
0 1 0 0
Output
20
Note

In the first example the following positions are good:

  1. the (1, 1) cell and right direction;
  2. the (1, 1) cell and down direction;
  3. the (1, 3) cell and left direction;
  4. the (1, 3) cell and down direction;
  5. the (1, 4) cell and left direction;
  6. the (2, 2) cell and left direction;
  7. the (2, 2) cell and up direction;
  8. the (2, 2) and right direction;
  9. the (2, 4) cell and left direction.

Therefore, there are 9 good positions in this example.

题意:就是看a[i][j]==0是它的4个方位有几个1;

代码:

#include<stdio.h>
#include<string.h>
int n,m,a[1200][1200],sum[1200][1200][4];
int main()
{
    while(~scanf("%d %d",&n,&m))
    {
        int ans=0;
        memset(a,0,sizeof(a));
        memset(sum,0,sizeof(sum));
        for(int i=1;i<=n;i++)//因为我们输入时从上至下、从左至右,所以先找我们输入的这个数的上方和左边有没有1;
        {
            for(int j=1;j<=m;j++)
            {
                scanf("%d",&a[i][j]);
                sum[i][j][0]=sum[i-1][j][0]|a[i][j];//如果它的上面一个的上方有1或自己是1,就标记它的上方是1;
                sum[i][j][1]=sum[i][j-1][1]|a[i][j];//如果它的左边一个的左边有1或自己是1,就标记它的左边是1;
            }
        }
        for(int i=n;i>0;i--)
        {
            for(int j=m;j>0;j--)
            {
                sum[i][j][2]=sum[i][j+1][2]|a[i][j];//同上
                sum[i][j][3]=sum[i+1][j][3]|a[i][j];//同上
            }
        }
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=m;j++)
            {
                if(a[i][j]==0)
                    ans+=sum[i][j][0]+sum[i][j][1]+sum[i][j][2]+sum[i][j][3];
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

### 使用 Stable Diffusion XL 进行空间设计的有效提示词 对于使用 Stable Diffusion XL (SDXL) 创建高质量的空间设计方案,构建有效的提示词至关重要。以下是几个有助于生成理想图像的建议和例子: #### 提示词结构的重要性 为了获得最佳效果,在编写提示词时应考虑多个方面,包括但不限于风格、材质、光照条件以及特定的设计元素。精确描述这些特征能够显著提升输出的质量。 #### 示例提示词 1. **现代简约客厅** ```plaintext A modern minimalist living room with large windows, white walls, wooden floors, and minimal furniture pieces arranged symmetrically. ``` 2. **复古工业风办公室** ```plaintext An industrial-style office space featuring exposed brick walls, metal beams on the ceiling, vintage light fixtures hanging from above, dark leather chairs around a long wooden table. ``` 3. **未来主义厨房概念** ```plaintext Futuristic kitchen design concept showcasing sleek stainless steel appliances integrated into smooth surfaces; LED lighting embedded within countertops creates an ethereal glow throughout the area. ``` 4. **自然融合住宅入口** ```plaintext Residential entrance blending seamlessly with nature through floor-to-ceiling glass doors opening onto lush gardens outside; stone pathways leading up to the door framed by tall bamboo plants. ``` 5. **艺术画廊内部视角** ```plaintext Interior view of an art gallery characterized by high ceilings supported by elegant columns, spotlights illuminating various artworks displayed along pristine white walls. ``` 通过上述实例可以看出,详细的场景描绘加上具体的技术参数可以引导 SDXL 更好地理解用户的意图并据此创作出更加贴近需求的作品[^1]。 ```python # Python code snippet demonstrating how one might programmatically generate prompts based on user input or preferences. def create_space_design_prompt(style, features): base = f"A {style} interior design" if isinstance(features, list): feature_string = ", ".join([f"{feature}" for feature in features]) full_prompt = f"{base}, including {feature_string}." else: full_prompt = f"{base}, highlighting {features}." return full_prompt print(create_space_design_prompt('modern', ['large windows', 'white walls'])) ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值