20252b
This commit is contained in:
35
thu20252b.cpp
Normal file
35
thu20252b.cpp
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int line_sums[1010];
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int T;
|
||||||
|
int n, m;
|
||||||
|
char linebuf[1010];
|
||||||
|
scanf("%d", &T);
|
||||||
|
for (int _ = 0; _ < T; _++) {
|
||||||
|
scanf("%d %d", &n, &m);
|
||||||
|
int line_odd_count = 0;
|
||||||
|
memset(line_sums, 0, sizeof(line_sums));
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
scanf("%s", linebuf);
|
||||||
|
int cur_line_xor = 0;
|
||||||
|
for (int j = 0; j < m; j++) {
|
||||||
|
cur_line_xor ^= linebuf[j] - '0';
|
||||||
|
line_sums[j] ^= linebuf[j] - '0';
|
||||||
|
}
|
||||||
|
if (cur_line_xor == 1) {
|
||||||
|
line_odd_count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int col_odd_count = 0;
|
||||||
|
for (int j = 0; j < m; j++) {
|
||||||
|
col_odd_count += line_sums[j];
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%d\n", col_odd_count > line_odd_count ? col_odd_count : line_odd_count);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user