# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
768866 | 2023-06-28T19:42:56 Z | danikoynov | Council (JOI23_council) | C++14 | 4000 ms | 164800 KB |
/** ____ ____ ____ ____ ____ ____ ||l |||e |||i |||n |||a |||d || ||__|||__|||__|||__|||__|||__|| |/__\|/__\|/__\|/__\|/__\|/__\| **/ #include<bits/stdc++.h> #define endl '\n' using namespace std; typedef long long ll; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } const int maxn = 3e5 + 10, maxm = 21; int n, m, imp[maxm], cnt[maxm]; bool a[maxn][maxm]; int dp[maxm][(1 << maxm)][2]; int val_mask[maxn], rev_mask[maxn]; void solve() { cin >> n >> m; for (int i = 1; i <= n; i ++) for (int j = 0; j < m; j ++) cin >> a[i][j], cnt[j] += a[i][j]; for (int mask = 0; mask < (1 << m); mask ++) for (int i = 0; i < m; i ++) dp[i][mask][0] = dp[i][mask][1] = -1; for (int i = 1; i <= n; i ++) for (int j = 0; j < m; j ++) { val_mask[i] = (val_mask[i] + (1 << j) * a[i][j]); rev_mask[i] = (rev_mask[i] + (1 << j) * (1 - a[i][j])); } for (int i = 1; i <= n; i ++) { int two = 0, one = 0, zero = 0; for (int j = 0; j < m; j ++) { if (cnt[j] >= n / 2 + 2) two |= (1 << j); else if (cnt[j] >= n / 2 + 1) one |= (1 << j); else if (cnt[j] >= n / 2) zero |= (1 << j); } int mask = 0, rev = 0; for (int j = m - 1; j >= 0; j --) { mask = mask * 2 + (a[i][j]); rev = rev * 2 + (1 - a[i][j]); } int ONE = two | (one & (rev)); int ZERO = (one & (mask)) | (zero & (rev)); /**cout << i << " : " << ONE << " : " << ZERO << endl; for (int bit = 0; bit < m; bit ++) if ((ZERO & (1 << bit)) > 0) cout << 1 << " "; else cout << 0 << " "; cout << endl;*/ int ans = 0; for (int p = 1; p <= n; p ++) { if (p == i) continue; ///cout << "here " << p << " " << ((rev_mask[p])) << endl; int cur = __builtin_popcount((rev_mask[p]) & ZERO); /**cout << "step " << p << endl; for (int bit = 0; bit < m; bit ++) if ((rev_mask[p] & (1 << bit)) > 0) cout << 1 << " "; else cout << 0 << " "; cout << endl;*/ if (cur > __builtin_popcount(ans)) ans = ((rev_mask[p]) & ZERO); ///ans = max(ans, __builtin_popcount((~val_mask[p]) & zero)); } ans |= ONE; cout << __builtin_popcount(ans) << endl; } } int main() { ///speed(); solve(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 724 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 151 ms | 164636 KB | Output is correct |
6 | Correct | 146 ms | 164800 KB | Output is correct |
7 | Correct | 144 ms | 164556 KB | Output is correct |
8 | Correct | 145 ms | 164624 KB | Output is correct |
9 | Correct | 150 ms | 164600 KB | Output is correct |
10 | Correct | 147 ms | 164596 KB | Output is correct |
11 | Correct | 147 ms | 164600 KB | Output is correct |
12 | Correct | 151 ms | 164580 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Correct | 0 ms | 340 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 | 340 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 0 ms | 468 KB | Output is correct |
23 | Correct | 0 ms | 340 KB | Output is correct |
24 | Correct | 0 ms | 340 KB | Output is correct |
25 | Correct | 0 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 0 ms | 340 KB | Output is correct |
28 | Correct | 0 ms | 340 KB | Output is correct |
29 | Correct | 0 ms | 340 KB | Output is correct |
30 | Correct | 0 ms | 468 KB | Output is correct |
31 | Correct | 1 ms | 468 KB | Output is correct |
32 | Correct | 0 ms | 340 KB | Output is correct |
33 | Correct | 0 ms | 340 KB | Output is correct |
34 | Correct | 0 ms | 340 KB | Output is correct |
35 | Correct | 1 ms | 340 KB | Output is correct |
36 | Correct | 0 ms | 340 KB | Output is correct |
37 | Correct | 1 ms | 340 KB | Output is correct |
38 | Correct | 0 ms | 340 KB | Output is correct |
39 | Correct | 1 ms | 468 KB | Output is correct |
40 | Correct | 1 ms | 468 KB | Output is correct |
41 | Correct | 2 ms | 2132 KB | Output is correct |
42 | Correct | 2 ms | 2132 KB | Output is correct |
43 | Correct | 2 ms | 2132 KB | Output is correct |
44 | Correct | 2 ms | 2132 KB | Output is correct |
45 | Correct | 2 ms | 2132 KB | Output is correct |
46 | Correct | 16 ms | 17748 KB | Output is correct |
47 | Correct | 15 ms | 17748 KB | Output is correct |
48 | Correct | 16 ms | 17824 KB | Output is correct |
49 | Correct | 15 ms | 17836 KB | Output is correct |
50 | Correct | 15 ms | 17856 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 724 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 151 ms | 164636 KB | Output is correct |
6 | Correct | 146 ms | 164800 KB | Output is correct |
7 | Correct | 144 ms | 164556 KB | Output is correct |
8 | Correct | 145 ms | 164624 KB | Output is correct |
9 | Correct | 150 ms | 164600 KB | Output is correct |
10 | Correct | 147 ms | 164596 KB | Output is correct |
11 | Correct | 147 ms | 164600 KB | Output is correct |
12 | Correct | 151 ms | 164580 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Correct | 0 ms | 340 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 | 340 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 0 ms | 468 KB | Output is correct |
23 | Correct | 0 ms | 340 KB | Output is correct |
24 | Correct | 0 ms | 340 KB | Output is correct |
25 | Correct | 0 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 0 ms | 340 KB | Output is correct |
28 | Correct | 0 ms | 340 KB | Output is correct |
29 | Correct | 0 ms | 340 KB | Output is correct |
30 | Correct | 0 ms | 468 KB | Output is correct |
31 | Correct | 1 ms | 468 KB | Output is correct |
32 | Correct | 0 ms | 340 KB | Output is correct |
33 | Correct | 0 ms | 340 KB | Output is correct |
34 | Correct | 0 ms | 340 KB | Output is correct |
35 | Correct | 1 ms | 340 KB | Output is correct |
36 | Correct | 0 ms | 340 KB | Output is correct |
37 | Correct | 1 ms | 340 KB | Output is correct |
38 | Correct | 0 ms | 340 KB | Output is correct |
39 | Correct | 1 ms | 468 KB | Output is correct |
40 | Correct | 1 ms | 468 KB | Output is correct |
41 | Correct | 2 ms | 2132 KB | Output is correct |
42 | Correct | 2 ms | 2132 KB | Output is correct |
43 | Correct | 2 ms | 2132 KB | Output is correct |
44 | Correct | 2 ms | 2132 KB | Output is correct |
45 | Correct | 2 ms | 2132 KB | Output is correct |
46 | Correct | 16 ms | 17748 KB | Output is correct |
47 | Correct | 15 ms | 17748 KB | Output is correct |
48 | Correct | 16 ms | 17824 KB | Output is correct |
49 | Correct | 15 ms | 17836 KB | Output is correct |
50 | Correct | 15 ms | 17856 KB | Output is correct |
51 | Correct | 195 ms | 164684 KB | Output is correct |
52 | Correct | 199 ms | 164684 KB | Output is correct |
53 | Correct | 204 ms | 164636 KB | Output is correct |
54 | Correct | 201 ms | 164684 KB | Output is correct |
55 | Correct | 47 ms | 340 KB | Output is correct |
56 | Correct | 68 ms | 17944 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Execution timed out | 4041 ms | 8816 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Execution timed out | 4041 ms | 8816 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Execution timed out | 4041 ms | 8816 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Execution timed out | 4041 ms | 8816 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 724 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 151 ms | 164636 KB | Output is correct |
6 | Correct | 146 ms | 164800 KB | Output is correct |
7 | Correct | 144 ms | 164556 KB | Output is correct |
8 | Correct | 145 ms | 164624 KB | Output is correct |
9 | Correct | 150 ms | 164600 KB | Output is correct |
10 | Correct | 147 ms | 164596 KB | Output is correct |
11 | Correct | 147 ms | 164600 KB | Output is correct |
12 | Correct | 151 ms | 164580 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Correct | 0 ms | 340 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 | 340 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 0 ms | 468 KB | Output is correct |
23 | Correct | 0 ms | 340 KB | Output is correct |
24 | Correct | 0 ms | 340 KB | Output is correct |
25 | Correct | 0 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 0 ms | 340 KB | Output is correct |
28 | Correct | 0 ms | 340 KB | Output is correct |
29 | Correct | 0 ms | 340 KB | Output is correct |
30 | Correct | 0 ms | 468 KB | Output is correct |
31 | Correct | 1 ms | 468 KB | Output is correct |
32 | Correct | 0 ms | 340 KB | Output is correct |
33 | Correct | 0 ms | 340 KB | Output is correct |
34 | Correct | 0 ms | 340 KB | Output is correct |
35 | Correct | 1 ms | 340 KB | Output is correct |
36 | Correct | 0 ms | 340 KB | Output is correct |
37 | Correct | 1 ms | 340 KB | Output is correct |
38 | Correct | 0 ms | 340 KB | Output is correct |
39 | Correct | 1 ms | 468 KB | Output is correct |
40 | Correct | 1 ms | 468 KB | Output is correct |
41 | Correct | 2 ms | 2132 KB | Output is correct |
42 | Correct | 2 ms | 2132 KB | Output is correct |
43 | Correct | 2 ms | 2132 KB | Output is correct |
44 | Correct | 2 ms | 2132 KB | Output is correct |
45 | Correct | 2 ms | 2132 KB | Output is correct |
46 | Correct | 16 ms | 17748 KB | Output is correct |
47 | Correct | 15 ms | 17748 KB | Output is correct |
48 | Correct | 16 ms | 17824 KB | Output is correct |
49 | Correct | 15 ms | 17836 KB | Output is correct |
50 | Correct | 15 ms | 17856 KB | Output is correct |
51 | Correct | 195 ms | 164684 KB | Output is correct |
52 | Correct | 199 ms | 164684 KB | Output is correct |
53 | Correct | 204 ms | 164636 KB | Output is correct |
54 | Correct | 201 ms | 164684 KB | Output is correct |
55 | Correct | 47 ms | 340 KB | Output is correct |
56 | Correct | 68 ms | 17944 KB | Output is correct |
57 | Correct | 0 ms | 340 KB | Output is correct |
58 | Execution timed out | 4041 ms | 8816 KB | Time limit exceeded |
59 | Halted | 0 ms | 0 KB | - |