답안 #893402

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
893402 2023-12-27T04:27:58 Z ksujay2 Council (JOI23_council) C++17
56 / 100
4000 ms 12208 KB
#include <bits/stdc++.h>
using namespace std;
const int BS = 550;
const int INF = 1e9;
int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int N, M; cin >> N >> M;
    vector<int> A(N);
    vector<int> cnt(M);
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < M; j++) {
            int a; cin >> a;
            A[i] += a << j;
            cnt[j] += a;
        }
    }
    vector<int> D;
    auto dp = [&] () {
        for(int i = 0; i < (1 << M); i++) {
            for(int j = 0; j < M; j++) {
                if((i & (1 << j)) > 0) {
                    D[i] = min(D[i], D[i ^ (1 << j)]);
                }
            }
        }
        for(int i = (1 << M) - 1; i >= 0; i--) {
            for(int j = 0; j < M; j++) {
                if((i & (1 << j)) == 0) {
                    D[i] = min(D[i], D[i ^ (1 << j)] + 1);
                }
            }
        }
    };
    for(int i = 0; i < N; i++) {
        if(i % BS == 0) {
            D = vector<int>(1 << M, INF);
            for(int j = 0; j < N; j++) {
                if(j < i || i + BS <= j) {
                    D[A[j]] = 0;
                }
            }
            dp();
        }
        int v = (1 << M) - 1;
        int ans = 0;
        for(int j = 0; j < M; j++) {
            int c = (cnt[j] - ((A[i] & (1 << j)) > 0));
            if(c == N / 2) {
                v ^= 1 << j;
            }
            if(c >= N / 2) ans++;
        }
        int best = D[v];
        for(int j = i - (i % BS); j < (i - (i % BS) + BS) && j < N; j++) {
            if(j != i) {
                best = min(best, __popcount(A[j] ^ (A[j] & v)));
            }
        }
        cout << ans - best << '\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 464 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 139 ms 4444 KB Output is correct
6 Correct 133 ms 4444 KB Output is correct
7 Correct 133 ms 4444 KB Output is correct
8 Correct 138 ms 4444 KB Output is correct
9 Correct 134 ms 4440 KB Output is correct
10 Correct 134 ms 4444 KB Output is correct
11 Correct 134 ms 4440 KB Output is correct
12 Correct 136 ms 4440 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 428 KB Output is correct
24 Correct 0 ms 452 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 452 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 344 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 2 ms 348 KB Output is correct
42 Correct 2 ms 348 KB Output is correct
43 Correct 2 ms 516 KB Output is correct
44 Correct 2 ms 344 KB Output is correct
45 Correct 3 ms 408 KB Output is correct
46 Correct 15 ms 1112 KB Output is correct
47 Correct 15 ms 856 KB Output is correct
48 Correct 15 ms 860 KB Output is correct
49 Correct 16 ms 860 KB Output is correct
50 Correct 16 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 464 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 139 ms 4444 KB Output is correct
6 Correct 133 ms 4444 KB Output is correct
7 Correct 133 ms 4444 KB Output is correct
8 Correct 138 ms 4444 KB Output is correct
9 Correct 134 ms 4440 KB Output is correct
10 Correct 134 ms 4444 KB Output is correct
11 Correct 134 ms 4440 KB Output is correct
12 Correct 136 ms 4440 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 428 KB Output is correct
24 Correct 0 ms 452 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 452 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 344 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 2 ms 348 KB Output is correct
42 Correct 2 ms 348 KB Output is correct
43 Correct 2 ms 516 KB Output is correct
44 Correct 2 ms 344 KB Output is correct
45 Correct 3 ms 408 KB Output is correct
46 Correct 15 ms 1112 KB Output is correct
47 Correct 15 ms 856 KB Output is correct
48 Correct 15 ms 860 KB Output is correct
49 Correct 16 ms 860 KB Output is correct
50 Correct 16 ms 860 KB Output is correct
51 Correct 825 ms 8664 KB Output is correct
52 Correct 814 ms 8892 KB Output is correct
53 Correct 815 ms 8656 KB Output is correct
54 Correct 819 ms 8668 KB Output is correct
55 Correct 5 ms 600 KB Output is correct
56 Correct 99 ms 1608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 344 ms 2152 KB Output is correct
3 Correct 326 ms 2132 KB Output is correct
4 Correct 325 ms 2360 KB Output is correct
5 Correct 348 ms 2132 KB Output is correct
6 Correct 464 ms 2072 KB Output is correct
7 Correct 546 ms 2216 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 600 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 344 ms 2152 KB Output is correct
3 Correct 326 ms 2132 KB Output is correct
4 Correct 325 ms 2360 KB Output is correct
5 Correct 348 ms 2132 KB Output is correct
6 Correct 464 ms 2072 KB Output is correct
7 Correct 546 ms 2216 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 600 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 0 ms 600 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 794 ms 2128 KB Output is correct
21 Correct 811 ms 2344 KB Output is correct
22 Correct 759 ms 2292 KB Output is correct
23 Correct 468 ms 2440 KB Output is correct
24 Correct 458 ms 2072 KB Output is correct
25 Correct 479 ms 2388 KB Output is correct
26 Correct 875 ms 2208 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 1 ms 600 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 344 ms 2152 KB Output is correct
3 Correct 326 ms 2132 KB Output is correct
4 Correct 325 ms 2360 KB Output is correct
5 Correct 348 ms 2132 KB Output is correct
6 Correct 464 ms 2072 KB Output is correct
7 Correct 546 ms 2216 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 600 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 0 ms 600 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 794 ms 2128 KB Output is correct
21 Correct 811 ms 2344 KB Output is correct
22 Correct 759 ms 2292 KB Output is correct
23 Correct 468 ms 2440 KB Output is correct
24 Correct 458 ms 2072 KB Output is correct
25 Correct 479 ms 2388 KB Output is correct
26 Correct 875 ms 2208 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 1 ms 600 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 1769 ms 2324 KB Output is correct
48 Correct 1330 ms 2048 KB Output is correct
49 Correct 1257 ms 9928 KB Output is correct
50 Correct 1427 ms 11012 KB Output is correct
51 Correct 1416 ms 10384 KB Output is correct
52 Correct 1501 ms 10688 KB Output is correct
53 Correct 1822 ms 10952 KB Output is correct
54 Correct 3 ms 344 KB Output is correct
55 Correct 3 ms 348 KB Output is correct
56 Correct 2 ms 348 KB Output is correct
57 Correct 2 ms 348 KB Output is correct
58 Correct 3 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 344 ms 2152 KB Output is correct
3 Correct 326 ms 2132 KB Output is correct
4 Correct 325 ms 2360 KB Output is correct
5 Correct 348 ms 2132 KB Output is correct
6 Correct 464 ms 2072 KB Output is correct
7 Correct 546 ms 2216 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 600 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 0 ms 600 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 794 ms 2128 KB Output is correct
21 Correct 811 ms 2344 KB Output is correct
22 Correct 759 ms 2292 KB Output is correct
23 Correct 468 ms 2440 KB Output is correct
24 Correct 458 ms 2072 KB Output is correct
25 Correct 479 ms 2388 KB Output is correct
26 Correct 875 ms 2208 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 1 ms 600 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 1769 ms 2324 KB Output is correct
48 Correct 1330 ms 2048 KB Output is correct
49 Correct 1257 ms 9928 KB Output is correct
50 Correct 1427 ms 11012 KB Output is correct
51 Correct 1416 ms 10384 KB Output is correct
52 Correct 1501 ms 10688 KB Output is correct
53 Correct 1822 ms 10952 KB Output is correct
54 Correct 3 ms 344 KB Output is correct
55 Correct 3 ms 348 KB Output is correct
56 Correct 2 ms 348 KB Output is correct
57 Correct 2 ms 348 KB Output is correct
58 Correct 3 ms 348 KB Output is correct
59 Execution timed out 4069 ms 12208 KB Time limit exceeded
60 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 464 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 139 ms 4444 KB Output is correct
6 Correct 133 ms 4444 KB Output is correct
7 Correct 133 ms 4444 KB Output is correct
8 Correct 138 ms 4444 KB Output is correct
9 Correct 134 ms 4440 KB Output is correct
10 Correct 134 ms 4444 KB Output is correct
11 Correct 134 ms 4440 KB Output is correct
12 Correct 136 ms 4440 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 428 KB Output is correct
24 Correct 0 ms 452 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 452 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 344 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 2 ms 348 KB Output is correct
42 Correct 2 ms 348 KB Output is correct
43 Correct 2 ms 516 KB Output is correct
44 Correct 2 ms 344 KB Output is correct
45 Correct 3 ms 408 KB Output is correct
46 Correct 15 ms 1112 KB Output is correct
47 Correct 15 ms 856 KB Output is correct
48 Correct 15 ms 860 KB Output is correct
49 Correct 16 ms 860 KB Output is correct
50 Correct 16 ms 860 KB Output is correct
51 Correct 825 ms 8664 KB Output is correct
52 Correct 814 ms 8892 KB Output is correct
53 Correct 815 ms 8656 KB Output is correct
54 Correct 819 ms 8668 KB Output is correct
55 Correct 5 ms 600 KB Output is correct
56 Correct 99 ms 1608 KB Output is correct
57 Correct 1 ms 348 KB Output is correct
58 Correct 344 ms 2152 KB Output is correct
59 Correct 326 ms 2132 KB Output is correct
60 Correct 325 ms 2360 KB Output is correct
61 Correct 348 ms 2132 KB Output is correct
62 Correct 464 ms 2072 KB Output is correct
63 Correct 546 ms 2216 KB Output is correct
64 Correct 1 ms 348 KB Output is correct
65 Correct 0 ms 348 KB Output is correct
66 Correct 0 ms 600 KB Output is correct
67 Correct 0 ms 348 KB Output is correct
68 Correct 0 ms 348 KB Output is correct
69 Correct 0 ms 348 KB Output is correct
70 Correct 0 ms 348 KB Output is correct
71 Correct 0 ms 348 KB Output is correct
72 Correct 0 ms 348 KB Output is correct
73 Correct 5 ms 348 KB Output is correct
74 Correct 0 ms 600 KB Output is correct
75 Correct 0 ms 348 KB Output is correct
76 Correct 794 ms 2128 KB Output is correct
77 Correct 811 ms 2344 KB Output is correct
78 Correct 759 ms 2292 KB Output is correct
79 Correct 468 ms 2440 KB Output is correct
80 Correct 458 ms 2072 KB Output is correct
81 Correct 479 ms 2388 KB Output is correct
82 Correct 875 ms 2208 KB Output is correct
83 Correct 1 ms 348 KB Output is correct
84 Correct 0 ms 348 KB Output is correct
85 Correct 0 ms 348 KB Output is correct
86 Correct 0 ms 348 KB Output is correct
87 Correct 0 ms 348 KB Output is correct
88 Correct 0 ms 348 KB Output is correct
89 Correct 0 ms 344 KB Output is correct
90 Correct 0 ms 344 KB Output is correct
91 Correct 1 ms 600 KB Output is correct
92 Correct 1 ms 348 KB Output is correct
93 Correct 0 ms 348 KB Output is correct
94 Correct 1 ms 348 KB Output is correct
95 Correct 0 ms 348 KB Output is correct
96 Correct 0 ms 348 KB Output is correct
97 Correct 0 ms 348 KB Output is correct
98 Correct 0 ms 348 KB Output is correct
99 Correct 0 ms 348 KB Output is correct
100 Correct 0 ms 348 KB Output is correct
101 Correct 1 ms 348 KB Output is correct
102 Correct 1 ms 348 KB Output is correct
103 Correct 1769 ms 2324 KB Output is correct
104 Correct 1330 ms 2048 KB Output is correct
105 Correct 1257 ms 9928 KB Output is correct
106 Correct 1427 ms 11012 KB Output is correct
107 Correct 1416 ms 10384 KB Output is correct
108 Correct 1501 ms 10688 KB Output is correct
109 Correct 1822 ms 10952 KB Output is correct
110 Correct 3 ms 344 KB Output is correct
111 Correct 3 ms 348 KB Output is correct
112 Correct 2 ms 348 KB Output is correct
113 Correct 2 ms 348 KB Output is correct
114 Correct 3 ms 348 KB Output is correct
115 Execution timed out 4069 ms 12208 KB Time limit exceeded
116 Halted 0 ms 0 KB -