답안 #931892

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
931892 2024-02-22T14:14:17 Z alextodoran Council (JOI23_council) C++17
33 / 100
4000 ms 17576 KB
/**
 _  _   __  _ _ _  _  _ _
 |a  ||t  ||o    d | |o  |
| __    _| | _ | __|  _ |
| __ |/_  | __  /__\ / _\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N_MAX = 300000;
const int M_MAX = 20;

int N, M;
bool vote[N_MAX][M_MAX];
int total[M_MAX];

struct Nirvana {
    int max1, max1i;
    int max2, max2i;
};

Nirvana max (const Nirvana &a, const Nirvana &b) {
    Nirvana c;
    c.max1 = max(a.max1, b.max1);
    c.max1i = (c.max1 == a.max1 ? a.max1i : b.max1i);
    c.max2 = 0; c.max2i = 0;
    if (a.max1 > c.max2 && a.max1i != c.max1i) {
        c.max2 = a.max1; c.max2i = a.max1i;
    }
    if (b.max1 > c.max2 && b.max1i != c.max1i) {
        c.max2 = b.max1; c.max2i = b.max1i;
    }
    if (a.max2 > c.max2 && a.max2i != c.max1i) {
        c.max2 = a.max2; c.max2i = a.max2i;
    }
    if (b.max2 > c.max2 && b.max2i != c.max1i) {
        c.max2 = b.max2; c.max2i = b.max2i;
    }
    return c;
}

Nirvana dp[1 << M_MAX];

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        int mask = 0;
        for (int j = 0; j < M; j++) {
            cin >> vote[i][j];
            mask ^= (!vote[i][j] << j);
            total[j] += vote[i][j];
        }
        int sub = mask;
        while (true) {
            dp[sub] = max(dp[sub], Nirvana{__builtin_popcount(sub), i, 0, 0});
            sub--;
            if (sub < 0) {
                break;
            }
            sub &= mask;
        }
    }
    for (int j = 0; j < M; j++) {
        int bit = (1 << j);
        for (int mask = bit; mask < (1 << M); mask = ((mask + 1) | bit)) {
            dp[mask] = max(dp[mask], dp[mask ^ bit]);
        }
    }
    for (int i = 0; i < N; i++) {
        int cnt_ok = 0;
        int mask_bonus = 0;
        for (int j = 0; j < M; j++) {
            if ((total[j] - vote[i][j] - 1) * 2 > N - 2) {
                cnt_ok++;
            } else if ((total[j] - vote[i][j] - 0) * 2 > N - 2) {
                mask_bonus ^= (1 << j);
            }
        }
        Nirvana a = dp[mask_bonus];
        cout << cnt_ok + (a.max1i != i ? a.max1 : a.max2) << "\n";
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 85 ms 16872 KB Output is correct
6 Correct 45 ms 16988 KB Output is correct
7 Correct 51 ms 16988 KB Output is correct
8 Correct 54 ms 16984 KB Output is correct
9 Correct 76 ms 16984 KB Output is correct
10 Correct 59 ms 17236 KB Output is correct
11 Correct 57 ms 16984 KB Output is correct
12 Correct 80 ms 16976 KB Output is correct
13 Correct 0 ms 2648 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 0 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2252 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2392 KB Output is correct
41 Correct 2 ms 2648 KB Output is correct
42 Correct 1 ms 2652 KB Output is correct
43 Correct 1 ms 2652 KB Output is correct
44 Correct 1 ms 2652 KB Output is correct
45 Correct 1 ms 2652 KB Output is correct
46 Correct 9 ms 4444 KB Output is correct
47 Correct 6 ms 4560 KB Output is correct
48 Correct 7 ms 4444 KB Output is correct
49 Correct 6 ms 4444 KB Output is correct
50 Correct 7 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 85 ms 16872 KB Output is correct
6 Correct 45 ms 16988 KB Output is correct
7 Correct 51 ms 16988 KB Output is correct
8 Correct 54 ms 16984 KB Output is correct
9 Correct 76 ms 16984 KB Output is correct
10 Correct 59 ms 17236 KB Output is correct
11 Correct 57 ms 16984 KB Output is correct
12 Correct 80 ms 16976 KB Output is correct
13 Correct 0 ms 2648 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 0 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2252 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2392 KB Output is correct
41 Correct 2 ms 2648 KB Output is correct
42 Correct 1 ms 2652 KB Output is correct
43 Correct 1 ms 2652 KB Output is correct
44 Correct 1 ms 2652 KB Output is correct
45 Correct 1 ms 2652 KB Output is correct
46 Correct 9 ms 4444 KB Output is correct
47 Correct 6 ms 4560 KB Output is correct
48 Correct 7 ms 4444 KB Output is correct
49 Correct 6 ms 4444 KB Output is correct
50 Correct 7 ms 4444 KB Output is correct
51 Correct 46 ms 16988 KB Output is correct
52 Execution timed out 4054 ms 17304 KB Time limit exceeded
53 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 48 ms 9892 KB Output is correct
3 Correct 47 ms 9808 KB Output is correct
4 Correct 33 ms 9308 KB Output is correct
5 Correct 51 ms 9812 KB Output is correct
6 Correct 40 ms 9296 KB Output is correct
7 Correct 52 ms 9812 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 48 ms 9892 KB Output is correct
3 Correct 47 ms 9808 KB Output is correct
4 Correct 33 ms 9308 KB Output is correct
5 Correct 51 ms 9812 KB Output is correct
6 Correct 40 ms 9296 KB Output is correct
7 Correct 52 ms 9812 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2648 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 230 ms 14696 KB Output is correct
21 Correct 205 ms 13940 KB Output is correct
22 Correct 198 ms 14016 KB Output is correct
23 Correct 167 ms 14896 KB Output is correct
24 Correct 1809 ms 14812 KB Output is correct
25 Correct 280 ms 14652 KB Output is correct
26 Correct 272 ms 14544 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 0 ms 2396 KB Output is correct
30 Correct 1 ms 2392 KB Output is correct
31 Correct 1 ms 2504 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2508 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2648 KB Output is correct
43 Correct 0 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 48 ms 9892 KB Output is correct
3 Correct 47 ms 9808 KB Output is correct
4 Correct 33 ms 9308 KB Output is correct
5 Correct 51 ms 9812 KB Output is correct
6 Correct 40 ms 9296 KB Output is correct
7 Correct 52 ms 9812 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2648 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 230 ms 14696 KB Output is correct
21 Correct 205 ms 13940 KB Output is correct
22 Correct 198 ms 14016 KB Output is correct
23 Correct 167 ms 14896 KB Output is correct
24 Correct 1809 ms 14812 KB Output is correct
25 Correct 280 ms 14652 KB Output is correct
26 Correct 272 ms 14544 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 0 ms 2396 KB Output is correct
30 Correct 1 ms 2392 KB Output is correct
31 Correct 1 ms 2504 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2508 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2648 KB Output is correct
43 Correct 0 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 1 ms 2392 KB Output is correct
47 Correct 482 ms 17200 KB Output is correct
48 Correct 420 ms 16536 KB Output is correct
49 Correct 448 ms 16432 KB Output is correct
50 Correct 246 ms 17576 KB Output is correct
51 Execution timed out 4033 ms 6064 KB Time limit exceeded
52 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 48 ms 9892 KB Output is correct
3 Correct 47 ms 9808 KB Output is correct
4 Correct 33 ms 9308 KB Output is correct
5 Correct 51 ms 9812 KB Output is correct
6 Correct 40 ms 9296 KB Output is correct
7 Correct 52 ms 9812 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2648 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 230 ms 14696 KB Output is correct
21 Correct 205 ms 13940 KB Output is correct
22 Correct 198 ms 14016 KB Output is correct
23 Correct 167 ms 14896 KB Output is correct
24 Correct 1809 ms 14812 KB Output is correct
25 Correct 280 ms 14652 KB Output is correct
26 Correct 272 ms 14544 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 0 ms 2396 KB Output is correct
30 Correct 1 ms 2392 KB Output is correct
31 Correct 1 ms 2504 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2508 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2648 KB Output is correct
43 Correct 0 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 1 ms 2392 KB Output is correct
47 Correct 482 ms 17200 KB Output is correct
48 Correct 420 ms 16536 KB Output is correct
49 Correct 448 ms 16432 KB Output is correct
50 Correct 246 ms 17576 KB Output is correct
51 Execution timed out 4033 ms 6064 KB Time limit exceeded
52 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 85 ms 16872 KB Output is correct
6 Correct 45 ms 16988 KB Output is correct
7 Correct 51 ms 16988 KB Output is correct
8 Correct 54 ms 16984 KB Output is correct
9 Correct 76 ms 16984 KB Output is correct
10 Correct 59 ms 17236 KB Output is correct
11 Correct 57 ms 16984 KB Output is correct
12 Correct 80 ms 16976 KB Output is correct
13 Correct 0 ms 2648 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 0 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2252 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2392 KB Output is correct
41 Correct 2 ms 2648 KB Output is correct
42 Correct 1 ms 2652 KB Output is correct
43 Correct 1 ms 2652 KB Output is correct
44 Correct 1 ms 2652 KB Output is correct
45 Correct 1 ms 2652 KB Output is correct
46 Correct 9 ms 4444 KB Output is correct
47 Correct 6 ms 4560 KB Output is correct
48 Correct 7 ms 4444 KB Output is correct
49 Correct 6 ms 4444 KB Output is correct
50 Correct 7 ms 4444 KB Output is correct
51 Correct 46 ms 16988 KB Output is correct
52 Execution timed out 4054 ms 17304 KB Time limit exceeded
53 Halted 0 ms 0 KB -