UOJ Logo

NOI.AC

IDSubmission IDProblemHackerOwnerResultSubmit timeJudge time
#138#196619#3433. CrisscrossZeardoeFATSuccess!2023-11-14 17:22:312023-11-14 17:22:32

Details

Extra Test:

Wrong Answer
time: 0ms
memory: 1192kb

input:

2 2
01
10

output:

1

result:

wrong answer 1st numbers differ - expected: '3', found: '1'

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#196619#3433. CrisscrossFAT9731ms2176kbC++11645b2023-10-29 08:39:262023-11-14 17:22:46

answer

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000;
char mp[maxn + 5][maxn + 5];
int sr[maxn + 5], sc[maxn + 5];
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) {
		scanf("%s", mp[i] + 1);
		for (int j = 1; j <= m; j++) sr[i] += mp[i][j] - '0';
	}
	for (int j = 1; j <= m; j++)
		for (int i = 1; i <= n; i++) sc[j] += mp[i][j] - '0';
	int ans = n + m + 1;
	for (int i = 1; i <= n; i++) ans -= sr[i] == m;
	for (int i = 1; i <= m; i++) ans -= sc[i] == n;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++) ans -= sr[i] == m - 1 && sc[j] == n - 1;
	printf("%d", ans);
}