用户输出
0
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#25739 | #1150. 1-01F.czq的疑惑矩阵 | Accepted | 100 | 5039 ms | 66004 K | C++ 17 / 857 B | LittleFall | 2020-06-28 21:07:16 |
#include <bits/stdc++.h>
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}
const int M = 24;
int save[M], rev[M]; //每行的值,取反的值
int bitCount[1 << M];
int main(void) {
for (int num = 1; num < (1 << M); ++num) {
bitCount[num] = bitCount[num >> 1] + (num & 1);
}
int n = read(), m = read();
for (int row = 0; row < n; ++row) {
for (int col = 0; col < m; ++col) {
save[row] |= read() << col;
}
rev[row] = (1 << m) - 1 - save[row];
}
int ans = n * m;
for (int mask = 0; mask < (1 << m); ++mask) {
int tmp = 0;
for (int row = 0; row < n; ++row) {
tmp += std::min(bitCount[save[row] ^ mask], bitCount[rev[row] ^ mask]);
}
ans = std::min(ans, tmp);
}
std::cout << ans << "\n";
return 0;
}
用户输出
4
系统信息
Exited with return code 0
用户输出
5
系统信息
Exited with return code 0
用户输出
5
系统信息
Exited with return code 0
用户输出
5
系统信息
Exited with return code 0
用户输出
0
系统信息
Exited with return code 0
用户输出
0
系统信息
Exited with return code 0
6 10
1 1 0 1 0 1 1 1 1 0
1 1 0 1 0 0 0 1 1 1
1 0 0 1 1 0 0 0 1 0
0 1 1 1 0 0 1 0 0 0
1 1 0 1 1 1 1 1
<25 bytes omitted>
用户输出
14
系统信息
Exited with return code 0
6 10
0 0 0 0 0 1 0 0 0 1
0 0 0 1 0 1 0 1 0 0
0 1 1 0 0 0 0 1 1 0
0 0 1 0 0 0 1 0 1 0
1 1 0 1 1 1 1 1
<25 bytes omitted>
用户输出
16
系统信息
Exited with return code 0
8 10
1 1 1 0 0 1 0 1 0 0
0 0 1 0 1 0 0 0 1 1
0 0 0 1 1 1 1 1 0 0
1 1 0 1 0 0 0 1 0 0
1 0 1 0 0 0 0 1
<65 bytes omitted>
用户输出
23
系统信息
Exited with return code 0
15 18
0 1 1 1 1 0 1 1 1 0 0 0 1 0 0 1 0 0
0 1 0 0 1 0 1 1 1 1 0 0 1 0 0 1 1 1
1 0 1 1 0 0 0 1 1 1 1
<446 bytes omitted>
用户输出
82
系统信息
Exited with return code 0
24 2
0 0
0 0
0 0
0 1
1 1
1 0
1 1
1 0
1 1
0 1
0 1
0 0
1 0
1 1
0 1
1 1
1 1
0 0
1 1
1 1
0 1
1 1
1 0
1 1
<1 byte omitted>
用户输出
9
系统信息
Exited with return code 0
19 5
1 1 1 0 1
0 0 1 1 1
1 0 1 0 1
0 1 0 0 1
1 0 1 0 1
0 0 1 1 1
1 0 0 0 0
0 1 1 0 0
0 0 0 0 1
0 0 0
<95 bytes omitted>
用户输出
27
系统信息
Exited with return code 0
19 9
0 1 1 1 0 1 1 0 0
1 0 1 0 1 0 1 1 1
0 1 1 0 1 1 1 1 1
1 0 0 0 1 0 1 1 0
1 0 1 1 0 0 1 0 1
1 1 0
<247 bytes omitted>
用户输出
51
系统信息
Exited with return code 0
21 2
0 0
0 0
1 1
1 0
0 1
1 1
0 1
0 0
1 0
0 1
0 0
0 0
1 1
0 1
1 0
0 0
0 0
0 1
0 0
0 1
1 1
用户输出
9
系统信息
Exited with return code 0
24 24
1 1 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 1 0 1 1 0 0 0
0 1 0 0 0 0 1 0 1 0 0 0 1 0 1 0 0 1 0 0 1 1 1
<1058 bytes omitted>
用户输出
207
系统信息
Exited with return code 0
24 24
0 0 0 0 0 1 0 0 0 0 1 0 1 0 1 1 1 1 0 1 1 0 1 1
0 1 0 1 1 0 1 1 1 0 1 0 0 0 1 1 0 1 1 0 0 1 0
<1058 bytes omitted>
用户输出
207
系统信息
Exited with return code 0
24 24
0 1 1 0 1 1 0 0 0 0 0 1 0 0 0 0 1 1 1 0 0 1 1 1
0 0 0 0 0 0 1 0 1 0 1 1 1 0 0 0 0 0 0 0 1 0 0
<1058 bytes omitted>
用户输出
203
系统信息
Exited with return code 0
24 24
0 1 0 1 1 0 1 1 1 0 0 0 0 1 0 1 0 0 1 1 0 1 1 0
1 1 1 0 1 0 0 0 0 0 1 1 1 1 1 0 1 1 1 1 0 1 0
<1058 bytes omitted>
用户输出
203
系统信息
Exited with return code 0