-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcf_1010a.cpp
More file actions
48 lines (36 loc) · 942 Bytes
/
cf_1010a.cpp
File metadata and controls
48 lines (36 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t; cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
vector<vector<int>> a(n, vector<int>(m));
for (int i = 0; i < n; ++i) {
string in; cin >> in;
for (int j = 0; j < m; ++j) {
a[i][j] = in[j] - '0';
}
}
int rows = 0;
int cols = 0;
for (int i = 0; i < n; ++i) {
int val = a[i][0];
for (int j = 1; j < m; ++j) {
val ^= a[i][j];
}
if (val == 1) rows++;
}
for (int j = 0; j < m; ++j) {
int val = a[0][j];
for (int i = 1; i < n; ++i) {
val ^= a[i][j];
}
if (val == 1) cols++;
}
cout << max(rows, cols) << '\n';
}
return 0;
}