UOJ Logo

NOI.AC

ID提交记录ID题目HackerOwner结果提交时间测评时间
#137#197795#3433. CrisscrossGoneend18112606231Failed.2023-11-14 17:20:492023-11-14 17:20:49

详细

Extra Test:

Accepted
time: 0ms
memory: 1204kb

input:

5 5
01111
10001
10001
10001
11111

output:

8

result:

ok 1 number(s): "8"

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#197795#3433. Crisscross1811260623197335ms2172kbC++689b2023-11-14 15:16:022023-11-14 17:29:20

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,m,x,sum[1001][1001],cnt,ans;
char a[1001][1001];
signed main()
{
    scanf("%lld %lld",&n,&m);
    for(int i=1;i<=n;i++)
    {
        cnt=0;
        scanf("\n");
        for(int j=1;j<=m;j++)
        {
            scanf("%c",&a[i][j]);
            if(a[i][j]=='0')
                cnt++;
        }
        if(cnt&&cnt!=1) 
            ans++;
    }
    for(int i=1;i<=m;i++)
    {
        cnt=0;
        for(int j=1;j<=n;j++)
        {
            if(a[j][i]=='0')
                cnt++;
        }
        if(cnt) 
            ans++;
    }
    printf("%lld",ans+1);
    return 0;
}