# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
769599 | 2023-06-29T20:31:13 Z | MilosMilutinovic | Council (JOI23_council) | C++14 | 4000 ms | 65140 KB |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 10; const int M = 21; int n, m, a[N][M], b[N][M], v[N], cnt[M], bst[1 << M], ans[N]; void dfs(int i, int x) { for (int j = 0; j < (1 << (m + 1)); j++) { if (__builtin_popcount(bst[j] & j) > __builtin_popcount(x & j)) { bst[j] = x; } } } int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { scanf("%d", &a[i][j]); } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cnt[j] += a[i][j]; } } for (int iter = 1; iter <= 2; iter++) { for (int i = 1; i <= n; i++) { v[i] = 0; for (int j = 1; j <= m; j++) { if (a[i][j] == 1) { v[i] += (1 << j); } } } for (int i = 0; i < (1 << M); i++) { bst[i] = i; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cnt[j] -= a[i][j]; } int msk = 0, good = 0; for (int j = 1; j <= m; j++) { if (cnt[j] == (n / 2)) { msk ^= (1 << j); } if (cnt[j] >= (n / 2)) { good += 1; } } ans[iter == 1 ? i : n - i + 1] = max(ans[iter == 1 ? i : n - i + 1], good - __builtin_popcount(bst[msk] & msk)); for (int j = 1; j <= m; j++) { cnt[j] += a[i][j]; } dfs(v[i], v[i]); } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { b[n - i + 1][j] = a[i][j]; } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { a[i][j] = b[i][j]; } } } for (int i = 1; i <= n; i++) { printf("%d\n", ans[i]); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 8532 KB | Output is correct |
2 | Correct | 5 ms | 8600 KB | Output is correct |
3 | Correct | 5 ms | 8532 KB | Output is correct |
4 | Correct | 4 ms | 8532 KB | Output is correct |
5 | Correct | 647 ms | 8532 KB | Output is correct |
6 | Execution timed out | 4074 ms | 8544 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 8532 KB | Output is correct |
2 | Correct | 5 ms | 8600 KB | Output is correct |
3 | Correct | 5 ms | 8532 KB | Output is correct |
4 | Correct | 4 ms | 8532 KB | Output is correct |
5 | Correct | 647 ms | 8532 KB | Output is correct |
6 | Execution timed out | 4074 ms | 8544 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 8532 KB | Output is correct |
2 | Correct | 117 ms | 61692 KB | Output is correct |
3 | Correct | 122 ms | 61724 KB | Output is correct |
4 | Correct | 99 ms | 61128 KB | Output is correct |
5 | Correct | 129 ms | 61764 KB | Output is correct |
6 | Correct | 97 ms | 61200 KB | Output is correct |
7 | Correct | 134 ms | 61640 KB | Output is correct |
8 | Correct | 4 ms | 8532 KB | Output is correct |
9 | Correct | 5 ms | 8500 KB | Output is correct |
10 | Correct | 5 ms | 8528 KB | Output is correct |
11 | Correct | 5 ms | 8532 KB | Output is correct |
12 | Correct | 5 ms | 8532 KB | Output is correct |
13 | Correct | 5 ms | 8532 KB | Output is correct |
14 | Correct | 5 ms | 8468 KB | Output is correct |
15 | Correct | 4 ms | 8532 KB | Output is correct |
16 | Correct | 5 ms | 8500 KB | Output is correct |
17 | Correct | 6 ms | 9020 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 8532 KB | Output is correct |
2 | Correct | 117 ms | 61692 KB | Output is correct |
3 | Correct | 122 ms | 61724 KB | Output is correct |
4 | Correct | 99 ms | 61128 KB | Output is correct |
5 | Correct | 129 ms | 61764 KB | Output is correct |
6 | Correct | 97 ms | 61200 KB | Output is correct |
7 | Correct | 134 ms | 61640 KB | Output is correct |
8 | Correct | 4 ms | 8532 KB | Output is correct |
9 | Correct | 5 ms | 8500 KB | Output is correct |
10 | Correct | 5 ms | 8528 KB | Output is correct |
11 | Correct | 5 ms | 8532 KB | Output is correct |
12 | Correct | 5 ms | 8532 KB | Output is correct |
13 | Correct | 5 ms | 8532 KB | Output is correct |
14 | Correct | 5 ms | 8468 KB | Output is correct |
15 | Correct | 4 ms | 8532 KB | Output is correct |
16 | Correct | 5 ms | 8500 KB | Output is correct |
17 | Correct | 6 ms | 9020 KB | Output is correct |
18 | Correct | 5 ms | 8500 KB | Output is correct |
19 | Correct | 4 ms | 8532 KB | Output is correct |
20 | Execution timed out | 4042 ms | 65140 KB | Time limit exceeded |
21 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 8532 KB | Output is correct |
2 | Correct | 117 ms | 61692 KB | Output is correct |
3 | Correct | 122 ms | 61724 KB | Output is correct |
4 | Correct | 99 ms | 61128 KB | Output is correct |
5 | Correct | 129 ms | 61764 KB | Output is correct |
6 | Correct | 97 ms | 61200 KB | Output is correct |
7 | Correct | 134 ms | 61640 KB | Output is correct |
8 | Correct | 4 ms | 8532 KB | Output is correct |
9 | Correct | 5 ms | 8500 KB | Output is correct |
10 | Correct | 5 ms | 8528 KB | Output is correct |
11 | Correct | 5 ms | 8532 KB | Output is correct |
12 | Correct | 5 ms | 8532 KB | Output is correct |
13 | Correct | 5 ms | 8532 KB | Output is correct |
14 | Correct | 5 ms | 8468 KB | Output is correct |
15 | Correct | 4 ms | 8532 KB | Output is correct |
16 | Correct | 5 ms | 8500 KB | Output is correct |
17 | Correct | 6 ms | 9020 KB | Output is correct |
18 | Correct | 5 ms | 8500 KB | Output is correct |
19 | Correct | 4 ms | 8532 KB | Output is correct |
20 | Execution timed out | 4042 ms | 65140 KB | Time limit exceeded |
21 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 8532 KB | Output is correct |
2 | Correct | 117 ms | 61692 KB | Output is correct |
3 | Correct | 122 ms | 61724 KB | Output is correct |
4 | Correct | 99 ms | 61128 KB | Output is correct |
5 | Correct | 129 ms | 61764 KB | Output is correct |
6 | Correct | 97 ms | 61200 KB | Output is correct |
7 | Correct | 134 ms | 61640 KB | Output is correct |
8 | Correct | 4 ms | 8532 KB | Output is correct |
9 | Correct | 5 ms | 8500 KB | Output is correct |
10 | Correct | 5 ms | 8528 KB | Output is correct |
11 | Correct | 5 ms | 8532 KB | Output is correct |
12 | Correct | 5 ms | 8532 KB | Output is correct |
13 | Correct | 5 ms | 8532 KB | Output is correct |
14 | Correct | 5 ms | 8468 KB | Output is correct |
15 | Correct | 4 ms | 8532 KB | Output is correct |
16 | Correct | 5 ms | 8500 KB | Output is correct |
17 | Correct | 6 ms | 9020 KB | Output is correct |
18 | Correct | 5 ms | 8500 KB | Output is correct |
19 | Correct | 4 ms | 8532 KB | Output is correct |
20 | Execution timed out | 4042 ms | 65140 KB | Time limit exceeded |
21 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 8532 KB | Output is correct |
2 | Correct | 5 ms | 8600 KB | Output is correct |
3 | Correct | 5 ms | 8532 KB | Output is correct |
4 | Correct | 4 ms | 8532 KB | Output is correct |
5 | Correct | 647 ms | 8532 KB | Output is correct |
6 | Execution timed out | 4074 ms | 8544 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |