UOJ Logo

NOI.AC

IDSubmission IDProblemHackerOwnerResultSubmit timeJudge time
#139#196991#3433. CrisscrossGoneendshizipingFailed.2023-11-14 17:27:232023-11-14 17:27:23

Details

Extra Test:

Accepted
time: 0ms
memory: 1256kb

input:

4 3
100
100
010
010

output:

8

result:

ok 1 number(s): "8"

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#196991#3433. Crisscrossshiziping9726ms2236kbC++11817b2023-11-04 15:55:482023-11-14 17:29:13

answer

#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define mp(Tx, Ty) make_pair(Tx, Ty)
#define For(Ti, Ta, Tb) for(auto Ti = (Ta); Ti <= (Tb); Ti++)
#define Dec(Ti, Ta, Tb) for(auto Ti = (Ta); Ti >= (Tb); Ti--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define range(Tx) begin(Tx),end(Tx)
const int N = 1005;
char a[N][N];
int n, m;
int main() {
	cin.tie(nullptr)->sync_with_stdio(false);
	cin >> n >> m;
	For(i, 1, n) cin >> a[i] + 1;
	long long ans = 1;
	For(i, 1, n) {
		int cnt = 0;
		For(j, 1, m) {
			cnt += (a[i][j] == '0');
		}
		if (cnt == 0) continue;
		if (cnt == 1) continue;
		ans++;
	}
	For(j, 1, m) {
		int cnt = 0;
		For(i, 1, n) {	
			cnt += (a[i][j] == '0');
		}
		if (cnt == 0) continue;
		ans++;
	}
	cout << ans;
	return 0;
}