#ifdef Home
#define _GLIBCXX_DEBUG
#endif // Home
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int N = 300300;
int arr[N], sum[22], memo[1<<14];
main() {
#ifdef Home
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif // Home
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m, n2;
cin >> n >> m;
n2 = n / 2;
map < int, int > mp;
for(int i = 0, k, t; i < n; ++ i) {
k = 0;
for(int j = m; j --> 0;) {
cin >> t;
k <<= 1;
k |= t;
sum[j] += t;
}
arr[i] = k;
++ mp[k];
}
for(int i = 0, k, ans, mn; i < n; ++ i) {
k = ans = 0;
mn = m;
for(int j = m; j --> 0;) {
ans += (sum[j] - (0 != ((1<<j)&arr[i]))) >= n2;
k <<= 1;
k |= (sum[j] - (0 != ((1<<j)&arr[i]))) == n2;
}
if(!memo[k]) {
for(auto &[key, val] : mp) {
if(key != arr[i] || val > 1) {
mn = min(mn, __builtin_popcount(k&key));
}
}
memo[k] = mn + 1;
} else {
mn = memo[k] - 1;
}
cout << ans - mn << '\n';
}
}
Compilation message
council.cpp:16:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
16 | main() {
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
38 ms |
2024 KB |
Output is correct |
3 |
Correct |
39 ms |
2000 KB |
Output is correct |
4 |
Correct |
28 ms |
2084 KB |
Output is correct |
5 |
Correct |
41 ms |
1988 KB |
Output is correct |
6 |
Correct |
32 ms |
2060 KB |
Output is correct |
7 |
Correct |
41 ms |
1996 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
38 ms |
2024 KB |
Output is correct |
3 |
Correct |
39 ms |
2000 KB |
Output is correct |
4 |
Correct |
28 ms |
2084 KB |
Output is correct |
5 |
Correct |
41 ms |
1988 KB |
Output is correct |
6 |
Correct |
32 ms |
2060 KB |
Output is correct |
7 |
Correct |
41 ms |
1996 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
151 ms |
1988 KB |
Output is correct |
21 |
Correct |
151 ms |
2016 KB |
Output is correct |
22 |
Correct |
142 ms |
1992 KB |
Output is correct |
23 |
Correct |
127 ms |
2272 KB |
Output is correct |
24 |
Correct |
131 ms |
1968 KB |
Output is correct |
25 |
Correct |
157 ms |
2040 KB |
Output is correct |
26 |
Correct |
173 ms |
2224 KB |
Output is correct |
27 |
Correct |
0 ms |
212 KB |
Output is correct |
28 |
Correct |
1 ms |
212 KB |
Output is correct |
29 |
Correct |
0 ms |
212 KB |
Output is correct |
30 |
Correct |
0 ms |
212 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Correct |
0 ms |
212 KB |
Output is correct |
33 |
Correct |
0 ms |
212 KB |
Output is correct |
34 |
Correct |
1 ms |
212 KB |
Output is correct |
35 |
Correct |
0 ms |
212 KB |
Output is correct |
36 |
Correct |
1 ms |
340 KB |
Output is correct |
37 |
Correct |
0 ms |
212 KB |
Output is correct |
38 |
Correct |
0 ms |
212 KB |
Output is correct |
39 |
Correct |
0 ms |
212 KB |
Output is correct |
40 |
Correct |
0 ms |
212 KB |
Output is correct |
41 |
Correct |
0 ms |
212 KB |
Output is correct |
42 |
Correct |
1 ms |
212 KB |
Output is correct |
43 |
Correct |
1 ms |
212 KB |
Output is correct |
44 |
Correct |
0 ms |
212 KB |
Output is correct |
45 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
38 ms |
2024 KB |
Output is correct |
3 |
Correct |
39 ms |
2000 KB |
Output is correct |
4 |
Correct |
28 ms |
2084 KB |
Output is correct |
5 |
Correct |
41 ms |
1988 KB |
Output is correct |
6 |
Correct |
32 ms |
2060 KB |
Output is correct |
7 |
Correct |
41 ms |
1996 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
151 ms |
1988 KB |
Output is correct |
21 |
Correct |
151 ms |
2016 KB |
Output is correct |
22 |
Correct |
142 ms |
1992 KB |
Output is correct |
23 |
Correct |
127 ms |
2272 KB |
Output is correct |
24 |
Correct |
131 ms |
1968 KB |
Output is correct |
25 |
Correct |
157 ms |
2040 KB |
Output is correct |
26 |
Correct |
173 ms |
2224 KB |
Output is correct |
27 |
Correct |
0 ms |
212 KB |
Output is correct |
28 |
Correct |
1 ms |
212 KB |
Output is correct |
29 |
Correct |
0 ms |
212 KB |
Output is correct |
30 |
Correct |
0 ms |
212 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Correct |
0 ms |
212 KB |
Output is correct |
33 |
Correct |
0 ms |
212 KB |
Output is correct |
34 |
Correct |
1 ms |
212 KB |
Output is correct |
35 |
Correct |
0 ms |
212 KB |
Output is correct |
36 |
Correct |
1 ms |
340 KB |
Output is correct |
37 |
Correct |
0 ms |
212 KB |
Output is correct |
38 |
Correct |
0 ms |
212 KB |
Output is correct |
39 |
Correct |
0 ms |
212 KB |
Output is correct |
40 |
Correct |
0 ms |
212 KB |
Output is correct |
41 |
Correct |
0 ms |
212 KB |
Output is correct |
42 |
Correct |
1 ms |
212 KB |
Output is correct |
43 |
Correct |
1 ms |
212 KB |
Output is correct |
44 |
Correct |
0 ms |
212 KB |
Output is correct |
45 |
Correct |
1 ms |
340 KB |
Output is correct |
46 |
Correct |
0 ms |
340 KB |
Output is correct |
47 |
Correct |
296 ms |
2236 KB |
Output is correct |
48 |
Correct |
225 ms |
2180 KB |
Output is correct |
49 |
Correct |
219 ms |
2228 KB |
Output is correct |
50 |
Correct |
175 ms |
2324 KB |
Output is correct |
51 |
Correct |
176 ms |
1960 KB |
Output is correct |
52 |
Correct |
241 ms |
2780 KB |
Output is correct |
53 |
Execution timed out |
4057 ms |
2476 KB |
Time limit exceeded |
54 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
38 ms |
2024 KB |
Output is correct |
3 |
Correct |
39 ms |
2000 KB |
Output is correct |
4 |
Correct |
28 ms |
2084 KB |
Output is correct |
5 |
Correct |
41 ms |
1988 KB |
Output is correct |
6 |
Correct |
32 ms |
2060 KB |
Output is correct |
7 |
Correct |
41 ms |
1996 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
151 ms |
1988 KB |
Output is correct |
21 |
Correct |
151 ms |
2016 KB |
Output is correct |
22 |
Correct |
142 ms |
1992 KB |
Output is correct |
23 |
Correct |
127 ms |
2272 KB |
Output is correct |
24 |
Correct |
131 ms |
1968 KB |
Output is correct |
25 |
Correct |
157 ms |
2040 KB |
Output is correct |
26 |
Correct |
173 ms |
2224 KB |
Output is correct |
27 |
Correct |
0 ms |
212 KB |
Output is correct |
28 |
Correct |
1 ms |
212 KB |
Output is correct |
29 |
Correct |
0 ms |
212 KB |
Output is correct |
30 |
Correct |
0 ms |
212 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Correct |
0 ms |
212 KB |
Output is correct |
33 |
Correct |
0 ms |
212 KB |
Output is correct |
34 |
Correct |
1 ms |
212 KB |
Output is correct |
35 |
Correct |
0 ms |
212 KB |
Output is correct |
36 |
Correct |
1 ms |
340 KB |
Output is correct |
37 |
Correct |
0 ms |
212 KB |
Output is correct |
38 |
Correct |
0 ms |
212 KB |
Output is correct |
39 |
Correct |
0 ms |
212 KB |
Output is correct |
40 |
Correct |
0 ms |
212 KB |
Output is correct |
41 |
Correct |
0 ms |
212 KB |
Output is correct |
42 |
Correct |
1 ms |
212 KB |
Output is correct |
43 |
Correct |
1 ms |
212 KB |
Output is correct |
44 |
Correct |
0 ms |
212 KB |
Output is correct |
45 |
Correct |
1 ms |
340 KB |
Output is correct |
46 |
Correct |
0 ms |
340 KB |
Output is correct |
47 |
Correct |
296 ms |
2236 KB |
Output is correct |
48 |
Correct |
225 ms |
2180 KB |
Output is correct |
49 |
Correct |
219 ms |
2228 KB |
Output is correct |
50 |
Correct |
175 ms |
2324 KB |
Output is correct |
51 |
Correct |
176 ms |
1960 KB |
Output is correct |
52 |
Correct |
241 ms |
2780 KB |
Output is correct |
53 |
Execution timed out |
4057 ms |
2476 KB |
Time limit exceeded |
54 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |