UOJ Logo

NOI.AC

IDSubmission IDProblemHackerOwnerResultSubmit timeJudge time
#151#197990#3433. CrisscrosswushuyuhsfzbzjrFailed.2024-10-19 14:35:142024-10-19 14:35:16

Details

Extra Test:

Invalid Input

input:

10000000000

output:


result:

FAIL Expected int32, but "10000000000" found (stdin)

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#197990#3433. Crisscrosshsfzbzjr10038ms2184kbC++11896b2023-11-16 21:09:002023-11-16 21:09:01

answer

#include<bits/stdc++.h>
using namespace std;
int n,m;
char mp[1010][1010];

namespace subtask1{
	void solve(){
		int cnt0=0;
		for(int i=1;i<=m;i++)if(mp[1][i]=='0')cnt0++;
		if(cnt0==0)printf("1\n");
		else if(cnt0==1)printf("2\n");
		else printf("%d\n",cnt0+2);
	}
}

namespace subtask2{
	int cntR[1010],cntC[1010];
	void solve(){
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++)cntR[i]+=(mp[i][j]=='1'),cntC[j]+=(mp[i][j]=='1');
		int ans=n+m+1;
		for(int i=1;i<=n;i++)
			if(cntR[i]==m)ans--;
		for(int j=1;j<=m;j++)
			if(cntC[j]==n)ans--;
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++)if(mp[i][j]=='0'){
				if(cntR[i]==m-1&&cntC[j]==n-1)ans--;
			}
		printf("%d\n",ans);
	}
}

int main(){
		
	scanf("%d %d",&n,&m);
	
	for(int i=1;i<=n;i++)
		scanf("%s",mp[i]+1);
		
	if(n==1)
		subtask1::solve();
	else
		subtask2::solve();
		
	return 0;
}