Submission #921556

# Submission time Handle Problem Language Result Execution time Memory
921556 2024-02-04T06:32:52 Z vjudge1 Council (JOI23_council) C++17
16 / 100
4000 ms 19280 KB
// I stand with PALESTINE




//#pragma GCC optimize("Ofast,O3")
//#pragma GCC target("avx,avx2")
#include "bits/stdc++.h"

using namespace std;
using ll = long long;

void solve() {
    int n, m;
    cin >> n >> m;
    vector a(n, vector(m, 0));
    vector<pair<int, int>> cnt(1 << m);
    vector<int> bta(n), have(m);
    auto upd = [&](int bt, int v) -> void {
        if (cnt[bt].first < v) cnt[bt] = make_pair(v, cnt[bt].first);
        else cnt[bt].second = max(cnt[bt].second, v);
    };
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
            if (!a[i][j]) bta[i] |= 1 << j;
            have[j] += a[i][j];
        }
        upd(bta[i], __builtin_popcount(bta[i]));
    }
    for (int bt = (1 << m) - 1; bt >= 0; bt--) {
        for (int j = 0; j < m; j++) {
            if (bt & (1 << j)) continue;
            upd(bt, cnt[bt | (1 << j)].first);
            upd(bt, cnt[bt | (1 << j)].second);
        }
        cnt[bt].first = min(cnt[bt].first, __builtin_popcount(bt));
        cnt[bt].second = min(cnt[bt].second, __builtin_popcount(bt));
    }
    for (int bt = 0; bt < (1 << m); bt++) {
        for (int j = 0; j < m; j++) {
            if (bt & (1 << j)) continue;
            upd(bt | 1 << j, cnt[bt].first);
            upd(bt | 1 << j, cnt[bt].second);
        }
    }
    for (int i = 0; i < n; i++) {
        int ans = 0, bt = 0;
        for (int j = 0; j < m; j++) {
            have[j] -= a[i][j];
            if (have[j] != n / 2) ans += have[j] > n / 2;
            else bt |= 1 << j;
            have[j] += a[i][j];
        }
        int mx = 0;
        for (int j = 0; j < n; j++) {
            if (i == j) continue;
            mx = max(mx, __builtin_popcount(bta[j] & bt));
        }
        ans += mx;
//        cout << ans << ' ' << bta[i] << ' ' << bt << ' ' << cnt[bt].first << ' ' << cnt[bt].second << endl;
//        if (__builtin_popcount(bta[i]) == cnt[bt].first) ans += cnt[bt].second;
//        else ans += cnt[bt].first;
        cout << ans << '\n';
    }
}

int main() {
    cin.tie(0)->sync_with_stdio(false);
#ifdef sunnatov
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int q = 1;
//    cin >> q;
    while (q--)  {
        solve();
        cout << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 156 ms 8540 KB Output is correct
6 Correct 180 ms 8536 KB Output is correct
7 Correct 174 ms 8536 KB Output is correct
8 Correct 166 ms 8792 KB Output is correct
9 Correct 160 ms 8536 KB Output is correct
10 Correct 163 ms 8540 KB Output is correct
11 Correct 174 ms 8540 KB Output is correct
12 Correct 153 ms 8536 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 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 1 ms 456 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 452 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 448 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 408 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 344 KB Output is correct
41 Correct 2 ms 472 KB Output is correct
42 Correct 3 ms 472 KB Output is correct
43 Correct 3 ms 348 KB Output is correct
44 Correct 2 ms 348 KB Output is correct
45 Correct 3 ms 348 KB Output is correct
46 Correct 18 ms 1372 KB Output is correct
47 Correct 24 ms 1372 KB Output is correct
48 Correct 19 ms 1372 KB Output is correct
49 Correct 20 ms 1480 KB Output is correct
50 Correct 18 ms 1372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 156 ms 8540 KB Output is correct
6 Correct 180 ms 8536 KB Output is correct
7 Correct 174 ms 8536 KB Output is correct
8 Correct 166 ms 8792 KB Output is correct
9 Correct 160 ms 8536 KB Output is correct
10 Correct 163 ms 8540 KB Output is correct
11 Correct 174 ms 8540 KB Output is correct
12 Correct 153 ms 8536 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 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 1 ms 456 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 452 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 448 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 408 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 344 KB Output is correct
41 Correct 2 ms 472 KB Output is correct
42 Correct 3 ms 472 KB Output is correct
43 Correct 3 ms 348 KB Output is correct
44 Correct 2 ms 348 KB Output is correct
45 Correct 3 ms 348 KB Output is correct
46 Correct 18 ms 1372 KB Output is correct
47 Correct 24 ms 1372 KB Output is correct
48 Correct 19 ms 1372 KB Output is correct
49 Correct 20 ms 1480 KB Output is correct
50 Correct 18 ms 1372 KB Output is correct
51 Correct 193 ms 9304 KB Output is correct
52 Correct 186 ms 9392 KB Output is correct
53 Correct 178 ms 9156 KB Output is correct
54 Correct 179 ms 9156 KB Output is correct
55 Correct 29 ms 604 KB Output is correct
56 Correct 51 ms 1920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Execution timed out 4003 ms 19280 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Execution timed out 4003 ms 19280 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Execution timed out 4003 ms 19280 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Execution timed out 4003 ms 19280 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 156 ms 8540 KB Output is correct
6 Correct 180 ms 8536 KB Output is correct
7 Correct 174 ms 8536 KB Output is correct
8 Correct 166 ms 8792 KB Output is correct
9 Correct 160 ms 8536 KB Output is correct
10 Correct 163 ms 8540 KB Output is correct
11 Correct 174 ms 8540 KB Output is correct
12 Correct 153 ms 8536 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 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 1 ms 456 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 452 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 448 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 408 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 344 KB Output is correct
41 Correct 2 ms 472 KB Output is correct
42 Correct 3 ms 472 KB Output is correct
43 Correct 3 ms 348 KB Output is correct
44 Correct 2 ms 348 KB Output is correct
45 Correct 3 ms 348 KB Output is correct
46 Correct 18 ms 1372 KB Output is correct
47 Correct 24 ms 1372 KB Output is correct
48 Correct 19 ms 1372 KB Output is correct
49 Correct 20 ms 1480 KB Output is correct
50 Correct 18 ms 1372 KB Output is correct
51 Correct 193 ms 9304 KB Output is correct
52 Correct 186 ms 9392 KB Output is correct
53 Correct 178 ms 9156 KB Output is correct
54 Correct 179 ms 9156 KB Output is correct
55 Correct 29 ms 604 KB Output is correct
56 Correct 51 ms 1920 KB Output is correct
57 Correct 1 ms 344 KB Output is correct
58 Execution timed out 4003 ms 19280 KB Time limit exceeded
59 Halted 0 ms 0 KB -