답안 #877629

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
877629 2023-11-23T11:25:42 Z LucaIlie Council (JOI23_council) C++17
56 / 100
4000 ms 13428 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 3e5;
const int MAX_M = 20;

int countVc[1 << MAX_M];
int vote[MAX_N], pro[MAX_M];

int main() {
    int n, m;

    cin >> n >> m;
    for ( int i = 0; i < n; i++ ) {
        for ( int b = 0; b < m; b++ ) {
            int x;
            cin >> x;
            vote[i] += (x << b);
            pro[b] += x;
        }
        countVc[vote[i]]++;
    }

    for ( int b = 0; b < m; b++ ) {
        for ( int mask = 0; mask < (1 << m); mask++ ) {
            if ( (mask >> b) & 1 )
                countVc[mask] += countVc[mask - (1 << b)];
        }
    }

    for ( int i = 0; i < n; i++ ) {
        vector<int> bits;
        int ap = 0;
        for ( int b = 0; b < m; b++ ) {
            int x = pro[b] - ((vote[i] >> b) & 1);
            if ( x > n / 2 )
                ap++;
            if ( x == n / 2 )
                bits.push_back( b );
        }

        int maxAp = ap;
        for ( int mask = 0; mask < (1 << bits.size()); mask++ ) {
            int vc = (1 << m) - 1;
            for ( int b = 0; b < bits.size(); b++ ) {
                if ( (mask >> b) & 1 )
                    vc -= (1 << bits[b]);
            }
            if ( countVc[vc] >= 2 || (((vote[i] & vc) != vote[i]) && countVc[vc] >= 1) )
                maxAp = max( maxAp, ap + __builtin_popcount( mask ) );
        }

        cout << maxAp << "\n";
    }

    return 0;
}

Compilation message

council.cpp: In function 'int main()':
council.cpp:46:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |             for ( int b = 0; b < bits.size(); b++ ) {
      |                              ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 678 ms 4524 KB Output is correct
6 Correct 17 ms 4444 KB Output is correct
7 Correct 15 ms 5468 KB Output is correct
8 Correct 18 ms 5716 KB Output is correct
9 Correct 17 ms 5464 KB Output is correct
10 Correct 17 ms 5532 KB Output is correct
11 Correct 18 ms 5464 KB Output is correct
12 Correct 62 ms 5520 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 0 ms 2488 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 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 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 0 ms 2496 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 2392 KB Output is correct
34 Correct 1 ms 2392 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 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 7 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 2652 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 66 ms 2396 KB Output is correct
47 Correct 2 ms 2396 KB Output is correct
48 Correct 2 ms 2396 KB Output is correct
49 Correct 4 ms 2496 KB Output is correct
50 Correct 4 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 678 ms 4524 KB Output is correct
6 Correct 17 ms 4444 KB Output is correct
7 Correct 15 ms 5468 KB Output is correct
8 Correct 18 ms 5716 KB Output is correct
9 Correct 17 ms 5464 KB Output is correct
10 Correct 17 ms 5532 KB Output is correct
11 Correct 18 ms 5464 KB Output is correct
12 Correct 62 ms 5520 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 0 ms 2488 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 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 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 0 ms 2496 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 2392 KB Output is correct
34 Correct 1 ms 2392 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 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 7 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 2652 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 66 ms 2396 KB Output is correct
47 Correct 2 ms 2396 KB Output is correct
48 Correct 2 ms 2396 KB Output is correct
49 Correct 4 ms 2496 KB Output is correct
50 Correct 4 ms 2396 KB Output is correct
51 Correct 23 ms 4440 KB Output is correct
52 Correct 23 ms 5468 KB Output is correct
53 Correct 23 ms 5516 KB Output is correct
54 Correct 519 ms 5464 KB Output is correct
55 Correct 2 ms 2396 KB Output is correct
56 Correct 150 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 81 ms 4220 KB Output is correct
3 Correct 82 ms 4424 KB Output is correct
4 Correct 50 ms 3668 KB Output is correct
5 Correct 94 ms 4420 KB Output is correct
6 Correct 57 ms 3664 KB Output is correct
7 Correct 100 ms 4312 KB Output is correct
8 Correct 1 ms 2464 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 1 ms 2488 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 2 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 81 ms 4220 KB Output is correct
3 Correct 82 ms 4424 KB Output is correct
4 Correct 50 ms 3668 KB Output is correct
5 Correct 94 ms 4420 KB Output is correct
6 Correct 57 ms 3664 KB Output is correct
7 Correct 100 ms 4312 KB Output is correct
8 Correct 1 ms 2464 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 1 ms 2488 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 2 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 480 ms 8908 KB Output is correct
21 Correct 434 ms 8404 KB Output is correct
22 Correct 411 ms 8668 KB Output is correct
23 Correct 342 ms 9424 KB Output is correct
24 Correct 331 ms 9172 KB Output is correct
25 Correct 345 ms 9124 KB Output is correct
26 Correct 643 ms 9372 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 0 ms 2488 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 0 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 0 ms 2396 KB Output is correct
33 Correct 1 ms 2692 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 0 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 0 ms 2396 KB Output is correct
40 Correct 1 ms 2500 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 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 1 ms 2396 KB Output is correct
2 Correct 81 ms 4220 KB Output is correct
3 Correct 82 ms 4424 KB Output is correct
4 Correct 50 ms 3668 KB Output is correct
5 Correct 94 ms 4420 KB Output is correct
6 Correct 57 ms 3664 KB Output is correct
7 Correct 100 ms 4312 KB Output is correct
8 Correct 1 ms 2464 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 1 ms 2488 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 2 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 480 ms 8908 KB Output is correct
21 Correct 434 ms 8404 KB Output is correct
22 Correct 411 ms 8668 KB Output is correct
23 Correct 342 ms 9424 KB Output is correct
24 Correct 331 ms 9172 KB Output is correct
25 Correct 345 ms 9124 KB Output is correct
26 Correct 643 ms 9372 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 0 ms 2488 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 0 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 0 ms 2396 KB Output is correct
33 Correct 1 ms 2692 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 0 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 0 ms 2396 KB Output is correct
40 Correct 1 ms 2500 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 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 2652 KB Output is correct
47 Correct 956 ms 11660 KB Output is correct
48 Correct 953 ms 10800 KB Output is correct
49 Correct 806 ms 10868 KB Output is correct
50 Correct 452 ms 11732 KB Output is correct
51 Correct 459 ms 11320 KB Output is correct
52 Correct 464 ms 11356 KB Output is correct
53 Correct 3846 ms 11724 KB Output is correct
54 Correct 7 ms 2492 KB Output is correct
55 Correct 1 ms 2396 KB Output is correct
56 Correct 1 ms 2396 KB Output is correct
57 Correct 1 ms 2396 KB Output is correct
58 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 81 ms 4220 KB Output is correct
3 Correct 82 ms 4424 KB Output is correct
4 Correct 50 ms 3668 KB Output is correct
5 Correct 94 ms 4420 KB Output is correct
6 Correct 57 ms 3664 KB Output is correct
7 Correct 100 ms 4312 KB Output is correct
8 Correct 1 ms 2464 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 1 ms 2488 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 2 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 480 ms 8908 KB Output is correct
21 Correct 434 ms 8404 KB Output is correct
22 Correct 411 ms 8668 KB Output is correct
23 Correct 342 ms 9424 KB Output is correct
24 Correct 331 ms 9172 KB Output is correct
25 Correct 345 ms 9124 KB Output is correct
26 Correct 643 ms 9372 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 0 ms 2488 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 0 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 0 ms 2396 KB Output is correct
33 Correct 1 ms 2692 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 0 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 0 ms 2396 KB Output is correct
40 Correct 1 ms 2500 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 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 2652 KB Output is correct
47 Correct 956 ms 11660 KB Output is correct
48 Correct 953 ms 10800 KB Output is correct
49 Correct 806 ms 10868 KB Output is correct
50 Correct 452 ms 11732 KB Output is correct
51 Correct 459 ms 11320 KB Output is correct
52 Correct 464 ms 11356 KB Output is correct
53 Correct 3846 ms 11724 KB Output is correct
54 Correct 7 ms 2492 KB Output is correct
55 Correct 1 ms 2396 KB Output is correct
56 Correct 1 ms 2396 KB Output is correct
57 Correct 1 ms 2396 KB Output is correct
58 Correct 1 ms 2396 KB Output is correct
59 Correct 561 ms 13428 KB Output is correct
60 Execution timed out 4022 ms 7028 KB Time limit exceeded
61 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 678 ms 4524 KB Output is correct
6 Correct 17 ms 4444 KB Output is correct
7 Correct 15 ms 5468 KB Output is correct
8 Correct 18 ms 5716 KB Output is correct
9 Correct 17 ms 5464 KB Output is correct
10 Correct 17 ms 5532 KB Output is correct
11 Correct 18 ms 5464 KB Output is correct
12 Correct 62 ms 5520 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 0 ms 2488 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 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 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 0 ms 2496 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 2392 KB Output is correct
34 Correct 1 ms 2392 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 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 7 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 2652 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 66 ms 2396 KB Output is correct
47 Correct 2 ms 2396 KB Output is correct
48 Correct 2 ms 2396 KB Output is correct
49 Correct 4 ms 2496 KB Output is correct
50 Correct 4 ms 2396 KB Output is correct
51 Correct 23 ms 4440 KB Output is correct
52 Correct 23 ms 5468 KB Output is correct
53 Correct 23 ms 5516 KB Output is correct
54 Correct 519 ms 5464 KB Output is correct
55 Correct 2 ms 2396 KB Output is correct
56 Correct 150 ms 2396 KB Output is correct
57 Correct 1 ms 2396 KB Output is correct
58 Correct 81 ms 4220 KB Output is correct
59 Correct 82 ms 4424 KB Output is correct
60 Correct 50 ms 3668 KB Output is correct
61 Correct 94 ms 4420 KB Output is correct
62 Correct 57 ms 3664 KB Output is correct
63 Correct 100 ms 4312 KB Output is correct
64 Correct 1 ms 2464 KB Output is correct
65 Correct 1 ms 2396 KB Output is correct
66 Correct 1 ms 2396 KB Output is correct
67 Correct 0 ms 2396 KB Output is correct
68 Correct 1 ms 2396 KB Output is correct
69 Correct 0 ms 2396 KB Output is correct
70 Correct 0 ms 2396 KB Output is correct
71 Correct 1 ms 2488 KB Output is correct
72 Correct 1 ms 2396 KB Output is correct
73 Correct 2 ms 2396 KB Output is correct
74 Correct 1 ms 2396 KB Output is correct
75 Correct 0 ms 2396 KB Output is correct
76 Correct 480 ms 8908 KB Output is correct
77 Correct 434 ms 8404 KB Output is correct
78 Correct 411 ms 8668 KB Output is correct
79 Correct 342 ms 9424 KB Output is correct
80 Correct 331 ms 9172 KB Output is correct
81 Correct 345 ms 9124 KB Output is correct
82 Correct 643 ms 9372 KB Output is correct
83 Correct 1 ms 2396 KB Output is correct
84 Correct 0 ms 2488 KB Output is correct
85 Correct 1 ms 2396 KB Output is correct
86 Correct 0 ms 2396 KB Output is correct
87 Correct 1 ms 2396 KB Output is correct
88 Correct 0 ms 2396 KB Output is correct
89 Correct 1 ms 2692 KB Output is correct
90 Correct 1 ms 2396 KB Output is correct
91 Correct 1 ms 2396 KB Output is correct
92 Correct 1 ms 2396 KB Output is correct
93 Correct 0 ms 2396 KB Output is correct
94 Correct 1 ms 2396 KB Output is correct
95 Correct 0 ms 2396 KB Output is correct
96 Correct 1 ms 2500 KB Output is correct
97 Correct 1 ms 2396 KB Output is correct
98 Correct 1 ms 2396 KB Output is correct
99 Correct 1 ms 2396 KB Output is correct
100 Correct 1 ms 2396 KB Output is correct
101 Correct 1 ms 2396 KB Output is correct
102 Correct 1 ms 2652 KB Output is correct
103 Correct 956 ms 11660 KB Output is correct
104 Correct 953 ms 10800 KB Output is correct
105 Correct 806 ms 10868 KB Output is correct
106 Correct 452 ms 11732 KB Output is correct
107 Correct 459 ms 11320 KB Output is correct
108 Correct 464 ms 11356 KB Output is correct
109 Correct 3846 ms 11724 KB Output is correct
110 Correct 7 ms 2492 KB Output is correct
111 Correct 1 ms 2396 KB Output is correct
112 Correct 1 ms 2396 KB Output is correct
113 Correct 1 ms 2396 KB Output is correct
114 Correct 1 ms 2396 KB Output is correct
115 Correct 561 ms 13428 KB Output is correct
116 Execution timed out 4022 ms 7028 KB Time limit exceeded
117 Halted 0 ms 0 KB -