Submission #889584

# Submission time Handle Problem Language Result Execution time Memory
889584 2023-12-20T03:27:51 Z vjudge1 Council (JOI23_council) C++17
33 / 100
4000 ms 53640 KB
#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
#define ar array
#define pb push_back
#define ln '\n'
#define int long long

using i64 = long long;

template <class F, class _S>
bool chmin(F &u, const _S &v){
    bool flag = false;
    if ( u > v ){
        u = v; flag |= true;
    }
    return flag;
}

template <class F, class _S>
bool chmax(F &u, const _S &v){
    bool flag = false;
    if ( u < v ){
        u = v; flag |= true;
    }
    return flag;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m; cin >> n >> m;
    vector <vector<int>> a(n, vector <int> (m));
    for ( auto &u: a ){
        for ( auto &v: u ) cin >> v;
    }
    vector <int> cnt(m);
    for ( int i = 0; i < n; i++ ){
        for ( int j = 0; j < m; j++ ){
            cnt[j] += a[i][j];
        }
    }
    int tot = 0;
    for ( auto &x: cnt ){
        tot += (x >= n / 2);
    }
    const int S = 1 << m;
    vector <ar<int,2>> us(S, {-1, -1});
    for ( int i = 0; i < n; i++ ){
        int b = 0;
        for ( int j = 0; j < m; j++ ){
            b |= a[i][j] << j;
        }
        if ( us[b][0] != -1 ){
            swap(us[b][0], us[b][1]);
        }
        us[b][0] = i;
    }
    for ( int i = 0; i < n; i++ ){
        int mx = 0, q = tot;
        auto tmp = cnt;
        int b = 0;
        for ( int j = 0; j < m; j++ ){
            if ( a[i][j] && tmp[j] == n / 2 ){
                --q;
            } tmp[j] -= a[i][j];
            if ( tmp[j] == n / 2 ){
                b |= 1 << j;
            }
        }
        for ( int mask = 0; mask < (1 << m); mask++ ){
            bool flag = false;
            for ( auto j: {0, 1} ){
                if ( us[mask][j] != -1 && us[mask][j] != i ){
                    flag = true;
                }
            }
            chmax(mx, flag * (q - __builtin_popcount(mask & b)));
        }
        cout << mx << ln;
    }

    cout << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 151 ms 16732 KB Output is correct
6 Correct 1160 ms 16732 KB Output is correct
7 Correct 23 ms 16728 KB Output is correct
8 Correct 81 ms 16732 KB Output is correct
9 Correct 1161 ms 16728 KB Output is correct
10 Correct 23 ms 16728 KB Output is correct
11 Correct 80 ms 16728 KB Output is correct
12 Correct 1169 ms 16732 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 600 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 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 2 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 1 ms 348 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 1 ms 600 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 2 ms 348 KB Output is correct
41 Correct 2 ms 604 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 2 ms 604 KB Output is correct
44 Correct 1 ms 604 KB Output is correct
45 Correct 2 ms 604 KB Output is correct
46 Correct 16 ms 2396 KB Output is correct
47 Correct 3 ms 2396 KB Output is correct
48 Correct 13 ms 2396 KB Output is correct
49 Correct 3 ms 2396 KB Output is correct
50 Correct 10 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 151 ms 16732 KB Output is correct
6 Correct 1160 ms 16732 KB Output is correct
7 Correct 23 ms 16728 KB Output is correct
8 Correct 81 ms 16732 KB Output is correct
9 Correct 1161 ms 16728 KB Output is correct
10 Correct 23 ms 16728 KB Output is correct
11 Correct 80 ms 16728 KB Output is correct
12 Correct 1169 ms 16732 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 600 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 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 2 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 1 ms 348 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 1 ms 600 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 2 ms 348 KB Output is correct
41 Correct 2 ms 604 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 2 ms 604 KB Output is correct
44 Correct 1 ms 604 KB Output is correct
45 Correct 2 ms 604 KB Output is correct
46 Correct 16 ms 2396 KB Output is correct
47 Correct 3 ms 2396 KB Output is correct
48 Correct 13 ms 2396 KB Output is correct
49 Correct 3 ms 2396 KB Output is correct
50 Correct 10 ms 2396 KB Output is correct
51 Execution timed out 4050 ms 17456 KB Time limit exceeded
52 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 63 ms 17236 KB Output is correct
3 Correct 62 ms 18516 KB Output is correct
4 Correct 51 ms 18004 KB Output is correct
5 Correct 71 ms 18512 KB Output is correct
6 Correct 50 ms 18248 KB Output is correct
7 Correct 68 ms 18512 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 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 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 63 ms 17236 KB Output is correct
3 Correct 62 ms 18516 KB Output is correct
4 Correct 51 ms 18004 KB Output is correct
5 Correct 71 ms 18512 KB Output is correct
6 Correct 50 ms 18248 KB Output is correct
7 Correct 68 ms 18512 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 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 1 ms 604 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1298 ms 42080 KB Output is correct
21 Correct 732 ms 36852 KB Output is correct
22 Correct 724 ms 37156 KB Output is correct
23 Correct 1266 ms 42568 KB Output is correct
24 Correct 1264 ms 42284 KB Output is correct
25 Correct 1290 ms 41924 KB Output is correct
26 Correct 1306 ms 42440 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 452 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 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 2 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 1 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 63 ms 17236 KB Output is correct
3 Correct 62 ms 18516 KB Output is correct
4 Correct 51 ms 18004 KB Output is correct
5 Correct 71 ms 18512 KB Output is correct
6 Correct 50 ms 18248 KB Output is correct
7 Correct 68 ms 18512 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 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 1 ms 604 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1298 ms 42080 KB Output is correct
21 Correct 732 ms 36852 KB Output is correct
22 Correct 724 ms 37156 KB Output is correct
23 Correct 1266 ms 42568 KB Output is correct
24 Correct 1264 ms 42284 KB Output is correct
25 Correct 1290 ms 41924 KB Output is correct
26 Correct 1306 ms 42440 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 452 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 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 2 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 1 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 2 ms 348 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Execution timed out 4011 ms 53640 KB Time limit exceeded
48 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 63 ms 17236 KB Output is correct
3 Correct 62 ms 18516 KB Output is correct
4 Correct 51 ms 18004 KB Output is correct
5 Correct 71 ms 18512 KB Output is correct
6 Correct 50 ms 18248 KB Output is correct
7 Correct 68 ms 18512 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 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 1 ms 604 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1298 ms 42080 KB Output is correct
21 Correct 732 ms 36852 KB Output is correct
22 Correct 724 ms 37156 KB Output is correct
23 Correct 1266 ms 42568 KB Output is correct
24 Correct 1264 ms 42284 KB Output is correct
25 Correct 1290 ms 41924 KB Output is correct
26 Correct 1306 ms 42440 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 452 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 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 2 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 1 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 2 ms 348 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Execution timed out 4011 ms 53640 KB Time limit exceeded
48 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 151 ms 16732 KB Output is correct
6 Correct 1160 ms 16732 KB Output is correct
7 Correct 23 ms 16728 KB Output is correct
8 Correct 81 ms 16732 KB Output is correct
9 Correct 1161 ms 16728 KB Output is correct
10 Correct 23 ms 16728 KB Output is correct
11 Correct 80 ms 16728 KB Output is correct
12 Correct 1169 ms 16732 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 600 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 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 2 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 1 ms 348 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 1 ms 600 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 2 ms 348 KB Output is correct
41 Correct 2 ms 604 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 2 ms 604 KB Output is correct
44 Correct 1 ms 604 KB Output is correct
45 Correct 2 ms 604 KB Output is correct
46 Correct 16 ms 2396 KB Output is correct
47 Correct 3 ms 2396 KB Output is correct
48 Correct 13 ms 2396 KB Output is correct
49 Correct 3 ms 2396 KB Output is correct
50 Correct 10 ms 2396 KB Output is correct
51 Execution timed out 4050 ms 17456 KB Time limit exceeded
52 Halted 0 ms 0 KB -