답안 #805725

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
805725 2023-08-03T21:51:15 Z someone Council (JOI23_council) C++14
16 / 100
4000 ms 8680 KB
#include <bits/stdc++.h>
//#define int long long
using namespace std;

const int N = 3e5 + 42, M = 20;

int n, m, mask[N], occ[N], maxi[1 << M][2];

void print(int val) {
    for(int i = 0; i < m; i++)
        cout << ((val & (1 << i)) > 0);
    cout << '\n';
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m;
    for(int i = 0; i < n; i++)
        mask[i] = (1 << m) - 1;
    for(int i = 0; i < m; i++)
        occ[i] = 0;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++) {
            int a; cin >> a;
            mask[i] -= a * (1 << j);
            occ[j] += a;
        }
    for(int i = 0; i < (1 << m); i++) {
        maxi[i][0] = M-2;
        maxi[i][1] = M-1;
    }
    /*
    for(int i = 0; i < n; i++) {
        if(maxi[mask[i]][0] >= M-2)
            maxi[mask[i]][0] = i;
        else
            maxi[mask[i]][1] = i;
    }
    for(int i = (1 << m)-1; i >= 0; i--) {
        for(int j = 0; j < m; j++) {
            if((i & (1 << j)) == 0) {
                if(maxi[i][0] >= M-2) {
                    maxi[i][0] = maxi[i + (1 << j)][0];
                    maxi[i][1] = maxi[i + (1 << j)][1];
                } else {
                    maxi[i][1] = maxi[i + (1 << j)][0];
                }
            }
        }
    }

    for(int i = 1; i < (1 << m); i++) {
        priority_queue<pair<int, int>> pq;
        pq.push({__builtin_popcount(i & mask[maxi[i][0]]), maxi[i][0]});
        pq.push({__builtin_popcount(i & mask[maxi[i][1]]), maxi[i][1]});
        for(int j = 0; j < m; j++)
            if(i & (1 << j)) {
                int id = i ^ (1 << j);
                pq.push({__builtin_popcount(i & mask[maxi[id][0]]), maxi[id][0]});
                pq.push({__builtin_popcount(i & mask[maxi[id][1]]), maxi[id][1]});
            }
        maxi[i][0] = pq.top().second;
        pq.pop();
        while(pq.top().second == maxi[i][0])
            pq.pop();
        maxi[i][1] = pq.top().second;
    }
    */

    for(int i = 0; i < n; i++) {
        int bmask = 0, nb = 0;
        //cout << '\n';
        for(int j = 0; j < m; j++) {
            if((1 << j) & (mask[i] ^ (1 << j)))
                occ[j]--;
            //cout << occ[j] << ' ';
            if(occ[j] == n/2)
                bmask += (1 << j);
            if(occ[j] >= n/2)
                nb++;
            if((1 << j) & (mask[i] ^ (1 << j)))
                occ[j]++;
        }
        //cout << '\n';
        //cout << nb << '\n';
        //print(bmask);
        int ans = 0;
        for(int j = 0; j < n; j++)
            if(j != i)
                ans = max(ans, nb - __builtin_popcount(bmask ^ (bmask & mask[j])));
        cout << ans << '\n';/*
        if(maxi[bmask][0] != i)
            cout << nb - __builtin_popcount(bmask ^ (bmask & mask[maxi[bmask][0]])) << '\n';
        else
            cout << nb - __builtin_popcount(bmask ^ (bmask & mask[maxi[bmask][1]])) << '\n';
        */
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 4 ms 8532 KB Output is correct
6 Correct 4 ms 8532 KB Output is correct
7 Correct 4 ms 8532 KB Output is correct
8 Correct 4 ms 8532 KB Output is correct
9 Correct 4 ms 8532 KB Output is correct
10 Correct 4 ms 8516 KB Output is correct
11 Correct 4 ms 8532 KB Output is correct
12 Correct 5 ms 8532 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 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 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 328 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 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 1 ms 340 KB Output is correct
36 Correct 0 ms 212 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 1 ms 340 KB Output is correct
41 Correct 1 ms 468 KB Output is correct
42 Correct 1 ms 460 KB Output is correct
43 Correct 1 ms 468 KB Output is correct
44 Correct 1 ms 468 KB Output is correct
45 Correct 1 ms 468 KB Output is correct
46 Correct 1 ms 1364 KB Output is correct
47 Correct 1 ms 1364 KB Output is correct
48 Correct 1 ms 1364 KB Output is correct
49 Correct 1 ms 1364 KB Output is correct
50 Correct 1 ms 1364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 4 ms 8532 KB Output is correct
6 Correct 4 ms 8532 KB Output is correct
7 Correct 4 ms 8532 KB Output is correct
8 Correct 4 ms 8532 KB Output is correct
9 Correct 4 ms 8532 KB Output is correct
10 Correct 4 ms 8516 KB Output is correct
11 Correct 4 ms 8532 KB Output is correct
12 Correct 5 ms 8532 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 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 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 328 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 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 1 ms 340 KB Output is correct
36 Correct 0 ms 212 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 1 ms 340 KB Output is correct
41 Correct 1 ms 468 KB Output is correct
42 Correct 1 ms 460 KB Output is correct
43 Correct 1 ms 468 KB Output is correct
44 Correct 1 ms 468 KB Output is correct
45 Correct 1 ms 468 KB Output is correct
46 Correct 1 ms 1364 KB Output is correct
47 Correct 1 ms 1364 KB Output is correct
48 Correct 1 ms 1364 KB Output is correct
49 Correct 1 ms 1364 KB Output is correct
50 Correct 1 ms 1364 KB Output is correct
51 Correct 30 ms 8680 KB Output is correct
52 Correct 30 ms 8656 KB Output is correct
53 Correct 31 ms 8676 KB Output is correct
54 Correct 31 ms 8660 KB Output is correct
55 Correct 31 ms 372 KB Output is correct
56 Correct 33 ms 1484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Execution timed out 4045 ms 1624 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Execution timed out 4045 ms 1624 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Execution timed out 4045 ms 1624 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Execution timed out 4045 ms 1624 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 4 ms 8532 KB Output is correct
6 Correct 4 ms 8532 KB Output is correct
7 Correct 4 ms 8532 KB Output is correct
8 Correct 4 ms 8532 KB Output is correct
9 Correct 4 ms 8532 KB Output is correct
10 Correct 4 ms 8516 KB Output is correct
11 Correct 4 ms 8532 KB Output is correct
12 Correct 5 ms 8532 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 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 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 328 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 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 1 ms 340 KB Output is correct
36 Correct 0 ms 212 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 1 ms 340 KB Output is correct
41 Correct 1 ms 468 KB Output is correct
42 Correct 1 ms 460 KB Output is correct
43 Correct 1 ms 468 KB Output is correct
44 Correct 1 ms 468 KB Output is correct
45 Correct 1 ms 468 KB Output is correct
46 Correct 1 ms 1364 KB Output is correct
47 Correct 1 ms 1364 KB Output is correct
48 Correct 1 ms 1364 KB Output is correct
49 Correct 1 ms 1364 KB Output is correct
50 Correct 1 ms 1364 KB Output is correct
51 Correct 30 ms 8680 KB Output is correct
52 Correct 30 ms 8656 KB Output is correct
53 Correct 31 ms 8676 KB Output is correct
54 Correct 31 ms 8660 KB Output is correct
55 Correct 31 ms 372 KB Output is correct
56 Correct 33 ms 1484 KB Output is correct
57 Correct 0 ms 340 KB Output is correct
58 Execution timed out 4045 ms 1624 KB Time limit exceeded
59 Halted 0 ms 0 KB -