Submission #739640

# Submission time Handle Problem Language Result Execution time Memory
739640 2023-05-10T21:33:56 Z sidon Council (JOI23_council) C++17
78 / 100
4000 ms 22432 KB
#include <bits/stdc++.h>
using namespace std;

const int B = 10;

array<int, 2> s[1<<B][1<<B][2];
int popcount[1<<B];

signed main() {
	cin.tie(0)->sync_with_stdio(0);

	for(int i = 0; i < (1<<B); ++i)
		popcount[i] = __builtin_popcount(i);
	
	int N, M; cin >> N >> M;
	int A[N] {}, c[M] {};

	for(int i = 0; i < N; ++i) {
		for(int j = 0; j < M; ++j) {
			int v; cin >> v;
			A[i] |= v << j;
			c[j] += v;
		}
		int x = A[i] >> B;

		for(int j = 0; j < (1<<B); ++j) {
			int v = popcount[j] - popcount[A[i] & j];
			if(v > s[x][j][0][0]) s[x][j][0] = {v, i};
			if(v > s[x][j][1][0]) swap(s[x][j][0], s[x][j][1]);
		}
	}

	for(int i = 0; i < N; ++i) {
		int ans {}, ext {}, x {};
		for(int j = 0; j < M; ++j) {
			int cur = c[j] - bool(A[i] & (1<<j));
			if(cur == N / 2) x |= 1<<j;
			if(cur  > N / 2) ++ext;
		}

		for(int j = 0; j < (1<<B); ++j)
			ans = max(ans, popcount[(x >> B)] - popcount[(x >> B) & j] + s[j][x & ((1<<B) - 1)][s[j][x & ((1<<B) - 1)][1][1] != i][0]);

		cout << ans + ext << '\n';
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 4 ms 340 KB Output is correct
7 Correct 2 ms 464 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 7 ms 5384 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 3 ms 724 KB Output is correct
12 Correct 9 ms 5344 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 4 ms 328 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 3 ms 328 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 3 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 4 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 3 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 2 ms 340 KB Output is correct
38 Correct 2 ms 360 KB Output is correct
39 Correct 3 ms 340 KB Output is correct
40 Correct 6 ms 328 KB Output is correct
41 Correct 2 ms 340 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 468 KB Output is correct
44 Correct 3 ms 340 KB Output is correct
45 Correct 2 ms 468 KB Output is correct
46 Correct 3 ms 468 KB Output is correct
47 Correct 2 ms 340 KB Output is correct
48 Correct 2 ms 724 KB Output is correct
49 Correct 2 ms 340 KB Output is correct
50 Correct 3 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 4 ms 340 KB Output is correct
7 Correct 2 ms 464 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 7 ms 5384 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 3 ms 724 KB Output is correct
12 Correct 9 ms 5344 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 4 ms 328 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 3 ms 328 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 3 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 4 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 3 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 2 ms 340 KB Output is correct
38 Correct 2 ms 360 KB Output is correct
39 Correct 3 ms 340 KB Output is correct
40 Correct 6 ms 328 KB Output is correct
41 Correct 2 ms 340 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 468 KB Output is correct
44 Correct 3 ms 340 KB Output is correct
45 Correct 2 ms 468 KB Output is correct
46 Correct 3 ms 468 KB Output is correct
47 Correct 2 ms 340 KB Output is correct
48 Correct 2 ms 724 KB Output is correct
49 Correct 2 ms 340 KB Output is correct
50 Correct 3 ms 596 KB Output is correct
51 Correct 27 ms 404 KB Output is correct
52 Correct 26 ms 340 KB Output is correct
53 Correct 48 ms 16004 KB Output is correct
54 Correct 62 ms 16140 KB Output is correct
55 Correct 27 ms 340 KB Output is correct
56 Correct 33 ms 2404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2226 ms 2460 KB Output is correct
3 Correct 2317 ms 2832 KB Output is correct
4 Correct 2313 ms 2404 KB Output is correct
5 Correct 2314 ms 2692 KB Output is correct
6 Correct 2259 ms 2460 KB Output is correct
7 Correct 2312 ms 2492 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 3 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 3 ms 340 KB Output is correct
17 Correct 24 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2226 ms 2460 KB Output is correct
3 Correct 2317 ms 2832 KB Output is correct
4 Correct 2313 ms 2404 KB Output is correct
5 Correct 2314 ms 2692 KB Output is correct
6 Correct 2259 ms 2460 KB Output is correct
7 Correct 2312 ms 2492 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 3 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 3 ms 340 KB Output is correct
17 Correct 24 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 2498 ms 3884 KB Output is correct
21 Correct 2432 ms 3612 KB Output is correct
22 Correct 2425 ms 3700 KB Output is correct
23 Correct 2395 ms 4316 KB Output is correct
24 Correct 2481 ms 3760 KB Output is correct
25 Correct 2401 ms 4100 KB Output is correct
26 Correct 2458 ms 4192 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 328 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 340 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 4 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 2 ms 340 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 2 ms 340 KB Output is correct
43 Correct 2 ms 340 KB Output is correct
44 Correct 3 ms 340 KB Output is correct
45 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2226 ms 2460 KB Output is correct
3 Correct 2317 ms 2832 KB Output is correct
4 Correct 2313 ms 2404 KB Output is correct
5 Correct 2314 ms 2692 KB Output is correct
6 Correct 2259 ms 2460 KB Output is correct
7 Correct 2312 ms 2492 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 3 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 3 ms 340 KB Output is correct
17 Correct 24 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 2498 ms 3884 KB Output is correct
21 Correct 2432 ms 3612 KB Output is correct
22 Correct 2425 ms 3700 KB Output is correct
23 Correct 2395 ms 4316 KB Output is correct
24 Correct 2481 ms 3760 KB Output is correct
25 Correct 2401 ms 4100 KB Output is correct
26 Correct 2458 ms 4192 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 328 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 340 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 4 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 2 ms 340 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 2 ms 340 KB Output is correct
43 Correct 2 ms 340 KB Output is correct
44 Correct 3 ms 340 KB Output is correct
45 Correct 5 ms 384 KB Output is correct
46 Correct 2 ms 340 KB Output is correct
47 Correct 2556 ms 5224 KB Output is correct
48 Correct 2523 ms 4776 KB Output is correct
49 Correct 2503 ms 4708 KB Output is correct
50 Correct 2406 ms 5008 KB Output is correct
51 Correct 2406 ms 4296 KB Output is correct
52 Correct 2438 ms 4692 KB Output is correct
53 Correct 2539 ms 4832 KB Output is correct
54 Correct 2 ms 340 KB Output is correct
55 Correct 1 ms 340 KB Output is correct
56 Correct 2 ms 468 KB Output is correct
57 Correct 3 ms 340 KB Output is correct
58 Correct 3 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2226 ms 2460 KB Output is correct
3 Correct 2317 ms 2832 KB Output is correct
4 Correct 2313 ms 2404 KB Output is correct
5 Correct 2314 ms 2692 KB Output is correct
6 Correct 2259 ms 2460 KB Output is correct
7 Correct 2312 ms 2492 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 3 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 3 ms 340 KB Output is correct
17 Correct 24 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 2498 ms 3884 KB Output is correct
21 Correct 2432 ms 3612 KB Output is correct
22 Correct 2425 ms 3700 KB Output is correct
23 Correct 2395 ms 4316 KB Output is correct
24 Correct 2481 ms 3760 KB Output is correct
25 Correct 2401 ms 4100 KB Output is correct
26 Correct 2458 ms 4192 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 328 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 340 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 4 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 2 ms 340 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 2 ms 340 KB Output is correct
43 Correct 2 ms 340 KB Output is correct
44 Correct 3 ms 340 KB Output is correct
45 Correct 5 ms 384 KB Output is correct
46 Correct 2 ms 340 KB Output is correct
47 Correct 2556 ms 5224 KB Output is correct
48 Correct 2523 ms 4776 KB Output is correct
49 Correct 2503 ms 4708 KB Output is correct
50 Correct 2406 ms 5008 KB Output is correct
51 Correct 2406 ms 4296 KB Output is correct
52 Correct 2438 ms 4692 KB Output is correct
53 Correct 2539 ms 4832 KB Output is correct
54 Correct 2 ms 340 KB Output is correct
55 Correct 1 ms 340 KB Output is correct
56 Correct 2 ms 468 KB Output is correct
57 Correct 3 ms 340 KB Output is correct
58 Correct 3 ms 468 KB Output is correct
59 Correct 2576 ms 5976 KB Output is correct
60 Correct 1043 ms 4196 KB Output is correct
61 Correct 1141 ms 4464 KB Output is correct
62 Correct 1137 ms 4532 KB Output is correct
63 Correct 2595 ms 6180 KB Output is correct
64 Correct 2626 ms 7968 KB Output is correct
65 Correct 2708 ms 7260 KB Output is correct
66 Correct 2468 ms 5504 KB Output is correct
67 Correct 2436 ms 5308 KB Output is correct
68 Correct 2614 ms 7712 KB Output is correct
69 Correct 2662 ms 7676 KB Output is correct
70 Correct 2 ms 468 KB Output is correct
71 Correct 2 ms 340 KB Output is correct
72 Correct 3 ms 724 KB Output is correct
73 Correct 2 ms 340 KB Output is correct
74 Correct 3 ms 596 KB Output is correct
75 Correct 33 ms 2440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 4 ms 340 KB Output is correct
7 Correct 2 ms 464 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 7 ms 5384 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 3 ms 724 KB Output is correct
12 Correct 9 ms 5344 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 4 ms 328 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 3 ms 328 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 3 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 4 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 3 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 2 ms 340 KB Output is correct
38 Correct 2 ms 360 KB Output is correct
39 Correct 3 ms 340 KB Output is correct
40 Correct 6 ms 328 KB Output is correct
41 Correct 2 ms 340 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 468 KB Output is correct
44 Correct 3 ms 340 KB Output is correct
45 Correct 2 ms 468 KB Output is correct
46 Correct 3 ms 468 KB Output is correct
47 Correct 2 ms 340 KB Output is correct
48 Correct 2 ms 724 KB Output is correct
49 Correct 2 ms 340 KB Output is correct
50 Correct 3 ms 596 KB Output is correct
51 Correct 27 ms 404 KB Output is correct
52 Correct 26 ms 340 KB Output is correct
53 Correct 48 ms 16004 KB Output is correct
54 Correct 62 ms 16140 KB Output is correct
55 Correct 27 ms 340 KB Output is correct
56 Correct 33 ms 2404 KB Output is correct
57 Correct 1 ms 340 KB Output is correct
58 Correct 2226 ms 2460 KB Output is correct
59 Correct 2317 ms 2832 KB Output is correct
60 Correct 2313 ms 2404 KB Output is correct
61 Correct 2314 ms 2692 KB Output is correct
62 Correct 2259 ms 2460 KB Output is correct
63 Correct 2312 ms 2492 KB Output is correct
64 Correct 1 ms 340 KB Output is correct
65 Correct 1 ms 340 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 1 ms 340 KB Output is correct
68 Correct 3 ms 340 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 1 ms 340 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 3 ms 340 KB Output is correct
73 Correct 24 ms 340 KB Output is correct
74 Correct 1 ms 340 KB Output is correct
75 Correct 1 ms 340 KB Output is correct
76 Correct 2498 ms 3884 KB Output is correct
77 Correct 2432 ms 3612 KB Output is correct
78 Correct 2425 ms 3700 KB Output is correct
79 Correct 2395 ms 4316 KB Output is correct
80 Correct 2481 ms 3760 KB Output is correct
81 Correct 2401 ms 4100 KB Output is correct
82 Correct 2458 ms 4192 KB Output is correct
83 Correct 2 ms 340 KB Output is correct
84 Correct 1 ms 340 KB Output is correct
85 Correct 1 ms 340 KB Output is correct
86 Correct 1 ms 328 KB Output is correct
87 Correct 2 ms 340 KB Output is correct
88 Correct 1 ms 340 KB Output is correct
89 Correct 2 ms 340 KB Output is correct
90 Correct 1 ms 336 KB Output is correct
91 Correct 1 ms 340 KB Output is correct
92 Correct 4 ms 340 KB Output is correct
93 Correct 1 ms 340 KB Output is correct
94 Correct 1 ms 340 KB Output is correct
95 Correct 1 ms 340 KB Output is correct
96 Correct 2 ms 340 KB Output is correct
97 Correct 1 ms 340 KB Output is correct
98 Correct 2 ms 340 KB Output is correct
99 Correct 2 ms 340 KB Output is correct
100 Correct 3 ms 340 KB Output is correct
101 Correct 5 ms 384 KB Output is correct
102 Correct 2 ms 340 KB Output is correct
103 Correct 2556 ms 5224 KB Output is correct
104 Correct 2523 ms 4776 KB Output is correct
105 Correct 2503 ms 4708 KB Output is correct
106 Correct 2406 ms 5008 KB Output is correct
107 Correct 2406 ms 4296 KB Output is correct
108 Correct 2438 ms 4692 KB Output is correct
109 Correct 2539 ms 4832 KB Output is correct
110 Correct 2 ms 340 KB Output is correct
111 Correct 1 ms 340 KB Output is correct
112 Correct 2 ms 468 KB Output is correct
113 Correct 3 ms 340 KB Output is correct
114 Correct 3 ms 468 KB Output is correct
115 Correct 2576 ms 5976 KB Output is correct
116 Correct 1043 ms 4196 KB Output is correct
117 Correct 1141 ms 4464 KB Output is correct
118 Correct 1137 ms 4532 KB Output is correct
119 Correct 2595 ms 6180 KB Output is correct
120 Correct 2626 ms 7968 KB Output is correct
121 Correct 2708 ms 7260 KB Output is correct
122 Correct 2468 ms 5504 KB Output is correct
123 Correct 2436 ms 5308 KB Output is correct
124 Correct 2614 ms 7712 KB Output is correct
125 Correct 2662 ms 7676 KB Output is correct
126 Correct 2 ms 468 KB Output is correct
127 Correct 2 ms 340 KB Output is correct
128 Correct 3 ms 724 KB Output is correct
129 Correct 2 ms 340 KB Output is correct
130 Correct 3 ms 596 KB Output is correct
131 Correct 33 ms 2440 KB Output is correct
132 Execution timed out 4093 ms 22432 KB Time limit exceeded
133 Halted 0 ms 0 KB -