-
Notifications
You must be signed in to change notification settings - Fork 1
/
P1034.cc
38 lines (38 loc) · 1.05 KB
/
P1034.cc
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
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0)->sync_with_stdio(0);
int n, m;
cin >> n >> m;
char table[50][51];
for (int i = 0; i < n; ++i) {
cin >> table[i];
}
int k;
cin >> k;
int max_yield = 0;
for (int i = 0; i < n; ++i) {
char table_if[50][51];
int changed = 0;
for (int j = 0; j < m; ++j) {
if (table[i][j] == '0') {
for (int t = 0; t < n; ++t) {
table_if[t][j] = table[t][j] == '0' ? '1' : '0';
}
++changed;
} else {
for (int t = 0; t < n; ++t) {
table_if[t][j] = table[t][j];
}
}
}
if (changed <= k && (changed & 1) == (k & 1)) {
int count = 0;
for (int j = 0; j < n; ++j) {
count += all_of(table_if[j], table_if[j] + m, [=](auto c){ return c == '1'; });
}
max_yield = max(max_yield, count);
}
}
cout << max_yield;
}