Submission #877776

# Submission time Handle Problem Language Result Execution time Memory
877776 2023-11-23T14:24:39 Z LucaIlie Council (JOI23_council) C++17
41 / 100
4000 ms 11636 KB
#include <bits/stdc++.h>

using namespace std;

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

struct aa {
    int x, y;

    void operator += ( const aa &a ) {
        if ( x == -1 ) {
            x = a.x;
            y = a.y;
        } else if ( y == -1 )
            y = a.x;
    }
};

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

int main() {
    int n, m;

    cin >> n >> m;
    for ( int mask = 0; mask < (1 << m); mask++ )
        countVc[mask] = { -1, -1 };
    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]] += { i, -1 };
    }

    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].x != -1 && (countVc[vc].x != i || (countVc[vc].y != -1 && countVc[vc].y != i)) )
                maxAp = max( maxAp, ap + __builtin_popcount( mask ) );
        }

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

    return 0;
}

Compilation message

council.cpp: In function 'int main()':
council.cpp:60:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |             for ( int b = 0; b < bits.size(); b++ ) {
      |                              ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 684 ms 9620 KB Output is correct
6 Correct 21 ms 9564 KB Output is correct
7 Correct 20 ms 9420 KB Output is correct
8 Correct 20 ms 9644 KB Output is correct
9 Correct 22 ms 9564 KB Output is correct
10 Correct 22 ms 9564 KB Output is correct
11 Correct 25 ms 9884 KB Output is correct
12 Correct 70 ms 9624 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 0 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 0 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 0 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 2400 KB Output is correct
26 Correct 1 ms 2496 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 2492 KB Output is correct
30 Correct 1 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 0 ms 2396 KB Output is correct
34 Correct 1 ms 2492 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 2492 KB Output is correct
40 Correct 2 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 2392 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 76 ms 2396 KB Output is correct
47 Correct 3 ms 2492 KB Output is correct
48 Correct 3 ms 2396 KB Output is correct
49 Correct 4 ms 2396 KB Output is correct
50 Correct 4 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 684 ms 9620 KB Output is correct
6 Correct 21 ms 9564 KB Output is correct
7 Correct 20 ms 9420 KB Output is correct
8 Correct 20 ms 9644 KB Output is correct
9 Correct 22 ms 9564 KB Output is correct
10 Correct 22 ms 9564 KB Output is correct
11 Correct 25 ms 9884 KB Output is correct
12 Correct 70 ms 9624 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 0 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 0 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 0 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 2400 KB Output is correct
26 Correct 1 ms 2496 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 2492 KB Output is correct
30 Correct 1 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 0 ms 2396 KB Output is correct
34 Correct 1 ms 2492 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 2492 KB Output is correct
40 Correct 2 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 2392 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 76 ms 2396 KB Output is correct
47 Correct 3 ms 2492 KB Output is correct
48 Correct 3 ms 2396 KB Output is correct
49 Correct 4 ms 2396 KB Output is correct
50 Correct 4 ms 2396 KB Output is correct
51 Correct 27 ms 9684 KB Output is correct
52 Correct 35 ms 9560 KB Output is correct
53 Correct 33 ms 9560 KB Output is correct
54 Correct 569 ms 9756 KB Output is correct
55 Correct 2 ms 2396 KB Output is correct
56 Correct 165 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 87 ms 4256 KB Output is correct
3 Correct 91 ms 4180 KB Output is correct
4 Correct 54 ms 3664 KB Output is correct
5 Correct 91 ms 4176 KB Output is correct
6 Correct 63 ms 3668 KB Output is correct
7 Correct 121 ms 4428 KB Output is correct
8 Correct 1 ms 2648 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 2492 KB Output is correct
14 Correct 1 ms 2400 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2404 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 87 ms 4256 KB Output is correct
3 Correct 91 ms 4180 KB Output is correct
4 Correct 54 ms 3664 KB Output is correct
5 Correct 91 ms 4176 KB Output is correct
6 Correct 63 ms 3668 KB Output is correct
7 Correct 121 ms 4428 KB Output is correct
8 Correct 1 ms 2648 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 2492 KB Output is correct
14 Correct 1 ms 2400 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2404 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2496 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 484 ms 8868 KB Output is correct
21 Correct 446 ms 8528 KB Output is correct
22 Correct 429 ms 8632 KB Output is correct
23 Correct 339 ms 9296 KB Output is correct
24 Correct 358 ms 8904 KB Output is correct
25 Correct 374 ms 9044 KB Output is correct
26 Correct 676 ms 9032 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 2488 KB Output is correct
30 Correct 1 ms 2392 KB Output is correct
31 Correct 1 ms 2592 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2404 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 2652 KB Output is correct
38 Correct 0 ms 2396 KB Output is correct
39 Correct 1 ms 2492 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 2392 KB Output is correct
43 Correct 0 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 2 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 87 ms 4256 KB Output is correct
3 Correct 91 ms 4180 KB Output is correct
4 Correct 54 ms 3664 KB Output is correct
5 Correct 91 ms 4176 KB Output is correct
6 Correct 63 ms 3668 KB Output is correct
7 Correct 121 ms 4428 KB Output is correct
8 Correct 1 ms 2648 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 2492 KB Output is correct
14 Correct 1 ms 2400 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2404 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2496 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 484 ms 8868 KB Output is correct
21 Correct 446 ms 8528 KB Output is correct
22 Correct 429 ms 8632 KB Output is correct
23 Correct 339 ms 9296 KB Output is correct
24 Correct 358 ms 8904 KB Output is correct
25 Correct 374 ms 9044 KB Output is correct
26 Correct 676 ms 9032 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 2488 KB Output is correct
30 Correct 1 ms 2392 KB Output is correct
31 Correct 1 ms 2592 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2404 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 2652 KB Output is correct
38 Correct 0 ms 2396 KB Output is correct
39 Correct 1 ms 2492 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 2392 KB Output is correct
43 Correct 0 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 2 ms 2396 KB Output is correct
46 Correct 1 ms 2396 KB Output is correct
47 Correct 951 ms 11460 KB Output is correct
48 Correct 942 ms 11240 KB Output is correct
49 Correct 878 ms 10640 KB Output is correct
50 Correct 474 ms 11596 KB Output is correct
51 Correct 492 ms 11296 KB Output is correct
52 Correct 511 ms 11332 KB Output is correct
53 Execution timed out 4049 ms 11636 KB Time limit exceeded
54 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 87 ms 4256 KB Output is correct
3 Correct 91 ms 4180 KB Output is correct
4 Correct 54 ms 3664 KB Output is correct
5 Correct 91 ms 4176 KB Output is correct
6 Correct 63 ms 3668 KB Output is correct
7 Correct 121 ms 4428 KB Output is correct
8 Correct 1 ms 2648 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 2492 KB Output is correct
14 Correct 1 ms 2400 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2404 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2496 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 484 ms 8868 KB Output is correct
21 Correct 446 ms 8528 KB Output is correct
22 Correct 429 ms 8632 KB Output is correct
23 Correct 339 ms 9296 KB Output is correct
24 Correct 358 ms 8904 KB Output is correct
25 Correct 374 ms 9044 KB Output is correct
26 Correct 676 ms 9032 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 2488 KB Output is correct
30 Correct 1 ms 2392 KB Output is correct
31 Correct 1 ms 2592 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2404 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 2652 KB Output is correct
38 Correct 0 ms 2396 KB Output is correct
39 Correct 1 ms 2492 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 2392 KB Output is correct
43 Correct 0 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 2 ms 2396 KB Output is correct
46 Correct 1 ms 2396 KB Output is correct
47 Correct 951 ms 11460 KB Output is correct
48 Correct 942 ms 11240 KB Output is correct
49 Correct 878 ms 10640 KB Output is correct
50 Correct 474 ms 11596 KB Output is correct
51 Correct 492 ms 11296 KB Output is correct
52 Correct 511 ms 11332 KB Output is correct
53 Execution timed out 4049 ms 11636 KB Time limit exceeded
54 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 684 ms 9620 KB Output is correct
6 Correct 21 ms 9564 KB Output is correct
7 Correct 20 ms 9420 KB Output is correct
8 Correct 20 ms 9644 KB Output is correct
9 Correct 22 ms 9564 KB Output is correct
10 Correct 22 ms 9564 KB Output is correct
11 Correct 25 ms 9884 KB Output is correct
12 Correct 70 ms 9624 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 0 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 0 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 0 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 2400 KB Output is correct
26 Correct 1 ms 2496 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 2492 KB Output is correct
30 Correct 1 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 0 ms 2396 KB Output is correct
34 Correct 1 ms 2492 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 2492 KB Output is correct
40 Correct 2 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 2392 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 76 ms 2396 KB Output is correct
47 Correct 3 ms 2492 KB Output is correct
48 Correct 3 ms 2396 KB Output is correct
49 Correct 4 ms 2396 KB Output is correct
50 Correct 4 ms 2396 KB Output is correct
51 Correct 27 ms 9684 KB Output is correct
52 Correct 35 ms 9560 KB Output is correct
53 Correct 33 ms 9560 KB Output is correct
54 Correct 569 ms 9756 KB Output is correct
55 Correct 2 ms 2396 KB Output is correct
56 Correct 165 ms 2396 KB Output is correct
57 Correct 1 ms 2396 KB Output is correct
58 Correct 87 ms 4256 KB Output is correct
59 Correct 91 ms 4180 KB Output is correct
60 Correct 54 ms 3664 KB Output is correct
61 Correct 91 ms 4176 KB Output is correct
62 Correct 63 ms 3668 KB Output is correct
63 Correct 121 ms 4428 KB Output is correct
64 Correct 1 ms 2648 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 2492 KB Output is correct
70 Correct 1 ms 2400 KB Output is correct
71 Correct 1 ms 2396 KB Output is correct
72 Correct 1 ms 2404 KB Output is correct
73 Correct 1 ms 2396 KB Output is correct
74 Correct 1 ms 2496 KB Output is correct
75 Correct 1 ms 2396 KB Output is correct
76 Correct 484 ms 8868 KB Output is correct
77 Correct 446 ms 8528 KB Output is correct
78 Correct 429 ms 8632 KB Output is correct
79 Correct 339 ms 9296 KB Output is correct
80 Correct 358 ms 8904 KB Output is correct
81 Correct 374 ms 9044 KB Output is correct
82 Correct 676 ms 9032 KB Output is correct
83 Correct 1 ms 2396 KB Output is correct
84 Correct 1 ms 2396 KB Output is correct
85 Correct 1 ms 2488 KB Output is correct
86 Correct 1 ms 2392 KB Output is correct
87 Correct 1 ms 2592 KB Output is correct
88 Correct 1 ms 2396 KB Output is correct
89 Correct 1 ms 2404 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 1 ms 2652 KB Output is correct
94 Correct 0 ms 2396 KB Output is correct
95 Correct 1 ms 2492 KB Output is correct
96 Correct 1 ms 2396 KB Output is correct
97 Correct 1 ms 2396 KB Output is correct
98 Correct 1 ms 2392 KB Output is correct
99 Correct 0 ms 2396 KB Output is correct
100 Correct 1 ms 2396 KB Output is correct
101 Correct 2 ms 2396 KB Output is correct
102 Correct 1 ms 2396 KB Output is correct
103 Correct 951 ms 11460 KB Output is correct
104 Correct 942 ms 11240 KB Output is correct
105 Correct 878 ms 10640 KB Output is correct
106 Correct 474 ms 11596 KB Output is correct
107 Correct 492 ms 11296 KB Output is correct
108 Correct 511 ms 11332 KB Output is correct
109 Execution timed out 4049 ms 11636 KB Time limit exceeded
110 Halted 0 ms 0 KB -