Submission #921620

# Submission time Handle Problem Language Result Execution time Memory
921620 2024-02-04T08:17:08 Z vjudge1 Council (JOI23_council) C++17
41 / 100
4000 ms 40572 KB
#pragma GCC optimize("unroll-loops")
#pragma gcc optimize("Ofast")
#pragma GCC optimization("Ofast")
#pragma optimize(Ofast)
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define str string
#define fastio ios::sync_with_stdio(0), cin.tie(0);
#define fs first
#define ss second
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define len(x) x.size()

#define print(a)          \
    for (auto &x : a)     \
        cout << x << " "; \
    cout << endl;

#define printmp(a)    \
    for (auto &x : a) \
        cout << x.fs << " " << x.ss << endl;

const int mod = 998244353;

void solve()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> a(n, vector<int>(m));
    map<vector<int>, int> dist;
    vector<vector<int>> p;
    for(int i = 0; i < n; i ++){
        for(int j = 0; j < m; j ++)
            cin >> a[i][j];
        if(dist.find(a[i]) == dist.end()){
            dist[a[i]] = p.size();
            p.push_back({});
            p[p.size() - 1].push_back(i);
        }
        else{
            p[dist[a[i]]].push_back(i);
        }
    }
    vector<int> cnt(m);
    for(int i = 0; i < n; i ++)
        for(int j = 0; j < m; j ++)
            cnt[j] += a[i][j];
    vector<int> ans(n);
    for(auto x : dist){
        vector<int> important;
        int res = 0;
        for(int j = 0; j < m; j ++){
            cnt[j] -= x.fs[j];
            if(cnt[j] == n / 2)
                important.push_back(j);
            if(cnt[j] >= n / 2)
                res ++;
        }
        int mn = res;
        for(auto y : dist){
            int nums = 0;
            if(y != x or p[x.ss].size() >= 2){
                for(auto k : important)
                    nums += y.fs[k];
                mn = min(mn, nums);
            }
        }
        for(auto y : p[x.ss])
            ans[y] = res - mn;
        for(int j = 0; j < m; j ++)
            cnt[j] += x.fs[j];
    }
    print(ans)
}

signed main()
{
    fastio int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
        // cout << endl;
    }
}

Compilation message

council.cpp:2: warning: ignoring '#pragma gcc optimize' [-Wunknown-pragmas]
    2 | #pragma gcc optimize("Ofast")
      | 
council.cpp:3: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    3 | #pragma GCC optimization("Ofast")
      | 
council.cpp:4: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    4 | #pragma optimize(Ofast)
      |
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 352 KB Output is correct
4 Correct 1 ms 356 KB Output is correct
5 Correct 1 ms 464 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 356 KB Output is correct
9 Correct 4 ms 356 KB Output is correct
10 Correct 0 ms 460 KB Output is correct
11 Correct 1 ms 356 KB Output is correct
12 Correct 4 ms 356 KB Output is correct
13 Correct 0 ms 352 KB Output is correct
14 Correct 0 ms 356 KB Output is correct
15 Correct 1 ms 356 KB Output is correct
16 Correct 0 ms 356 KB Output is correct
17 Correct 1 ms 356 KB Output is correct
18 Correct 1 ms 356 KB Output is correct
19 Correct 1 ms 504 KB Output is correct
20 Correct 1 ms 464 KB Output is correct
21 Correct 1 ms 356 KB Output is correct
22 Correct 1 ms 464 KB Output is correct
23 Correct 0 ms 356 KB Output is correct
24 Correct 0 ms 356 KB Output is correct
25 Correct 0 ms 356 KB Output is correct
26 Correct 1 ms 352 KB Output is correct
27 Correct 1 ms 356 KB Output is correct
28 Correct 1 ms 356 KB Output is correct
29 Correct 1 ms 356 KB Output is correct
30 Correct 1 ms 356 KB Output is correct
31 Correct 4 ms 356 KB Output is correct
32 Correct 1 ms 356 KB Output is correct
33 Correct 0 ms 464 KB Output is correct
34 Correct 1 ms 356 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 344 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 3 ms 344 KB Output is correct
41 Correct 1 ms 344 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 1 ms 604 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 1 ms 344 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 352 KB Output is correct
4 Correct 1 ms 356 KB Output is correct
5 Correct 1 ms 464 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 356 KB Output is correct
9 Correct 4 ms 356 KB Output is correct
10 Correct 0 ms 460 KB Output is correct
11 Correct 1 ms 356 KB Output is correct
12 Correct 4 ms 356 KB Output is correct
13 Correct 0 ms 352 KB Output is correct
14 Correct 0 ms 356 KB Output is correct
15 Correct 1 ms 356 KB Output is correct
16 Correct 0 ms 356 KB Output is correct
17 Correct 1 ms 356 KB Output is correct
18 Correct 1 ms 356 KB Output is correct
19 Correct 1 ms 504 KB Output is correct
20 Correct 1 ms 464 KB Output is correct
21 Correct 1 ms 356 KB Output is correct
22 Correct 1 ms 464 KB Output is correct
23 Correct 0 ms 356 KB Output is correct
24 Correct 0 ms 356 KB Output is correct
25 Correct 0 ms 356 KB Output is correct
26 Correct 1 ms 352 KB Output is correct
27 Correct 1 ms 356 KB Output is correct
28 Correct 1 ms 356 KB Output is correct
29 Correct 1 ms 356 KB Output is correct
30 Correct 1 ms 356 KB Output is correct
31 Correct 4 ms 356 KB Output is correct
32 Correct 1 ms 356 KB Output is correct
33 Correct 0 ms 464 KB Output is correct
34 Correct 1 ms 356 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 344 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 3 ms 344 KB Output is correct
41 Correct 1 ms 344 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 1 ms 604 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 1 ms 344 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 3 ms 856 KB Output is correct
52 Correct 3 ms 860 KB Output is correct
53 Correct 363 ms 1604 KB Output is correct
54 Correct 393 ms 1624 KB Output is correct
55 Correct 1 ms 600 KB Output is correct
56 Correct 353 ms 1488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 72 ms 20940 KB Output is correct
3 Correct 70 ms 21124 KB Output is correct
4 Correct 45 ms 20648 KB Output is correct
5 Correct 61 ms 21376 KB Output is correct
6 Correct 46 ms 20480 KB Output is correct
7 Correct 61 ms 21124 KB Output is correct
8 Correct 1 ms 452 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 452 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 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 344 KB Output is correct
2 Correct 72 ms 20940 KB Output is correct
3 Correct 70 ms 21124 KB Output is correct
4 Correct 45 ms 20648 KB Output is correct
5 Correct 61 ms 21376 KB Output is correct
6 Correct 46 ms 20480 KB Output is correct
7 Correct 61 ms 21124 KB Output is correct
8 Correct 1 ms 452 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 452 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 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 0 ms 348 KB Output is correct
20 Correct 200 ms 30860 KB Output is correct
21 Correct 178 ms 30544 KB Output is correct
22 Correct 184 ms 31052 KB Output is correct
23 Correct 156 ms 30112 KB Output is correct
24 Correct 164 ms 29892 KB Output is correct
25 Correct 270 ms 31220 KB Output is correct
26 Correct 269 ms 31196 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 456 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 344 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 456 KB Output is correct
36 Correct 3 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 456 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 344 KB Output is correct
45 Correct 3 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 72 ms 20940 KB Output is correct
3 Correct 70 ms 21124 KB Output is correct
4 Correct 45 ms 20648 KB Output is correct
5 Correct 61 ms 21376 KB Output is correct
6 Correct 46 ms 20480 KB Output is correct
7 Correct 61 ms 21124 KB Output is correct
8 Correct 1 ms 452 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 452 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 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 0 ms 348 KB Output is correct
20 Correct 200 ms 30860 KB Output is correct
21 Correct 178 ms 30544 KB Output is correct
22 Correct 184 ms 31052 KB Output is correct
23 Correct 156 ms 30112 KB Output is correct
24 Correct 164 ms 29892 KB Output is correct
25 Correct 270 ms 31220 KB Output is correct
26 Correct 269 ms 31196 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 456 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 344 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 456 KB Output is correct
36 Correct 3 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 456 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 344 KB Output is correct
45 Correct 3 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 773 ms 38320 KB Output is correct
48 Correct 428 ms 37596 KB Output is correct
49 Correct 417 ms 37616 KB Output is correct
50 Correct 215 ms 37116 KB Output is correct
51 Correct 204 ms 36788 KB Output is correct
52 Execution timed out 4016 ms 40572 KB Time limit exceeded
53 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 72 ms 20940 KB Output is correct
3 Correct 70 ms 21124 KB Output is correct
4 Correct 45 ms 20648 KB Output is correct
5 Correct 61 ms 21376 KB Output is correct
6 Correct 46 ms 20480 KB Output is correct
7 Correct 61 ms 21124 KB Output is correct
8 Correct 1 ms 452 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 452 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 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 0 ms 348 KB Output is correct
20 Correct 200 ms 30860 KB Output is correct
21 Correct 178 ms 30544 KB Output is correct
22 Correct 184 ms 31052 KB Output is correct
23 Correct 156 ms 30112 KB Output is correct
24 Correct 164 ms 29892 KB Output is correct
25 Correct 270 ms 31220 KB Output is correct
26 Correct 269 ms 31196 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 456 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 344 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 456 KB Output is correct
36 Correct 3 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 456 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 344 KB Output is correct
45 Correct 3 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 773 ms 38320 KB Output is correct
48 Correct 428 ms 37596 KB Output is correct
49 Correct 417 ms 37616 KB Output is correct
50 Correct 215 ms 37116 KB Output is correct
51 Correct 204 ms 36788 KB Output is correct
52 Execution timed out 4016 ms 40572 KB Time limit exceeded
53 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 352 KB Output is correct
4 Correct 1 ms 356 KB Output is correct
5 Correct 1 ms 464 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 356 KB Output is correct
9 Correct 4 ms 356 KB Output is correct
10 Correct 0 ms 460 KB Output is correct
11 Correct 1 ms 356 KB Output is correct
12 Correct 4 ms 356 KB Output is correct
13 Correct 0 ms 352 KB Output is correct
14 Correct 0 ms 356 KB Output is correct
15 Correct 1 ms 356 KB Output is correct
16 Correct 0 ms 356 KB Output is correct
17 Correct 1 ms 356 KB Output is correct
18 Correct 1 ms 356 KB Output is correct
19 Correct 1 ms 504 KB Output is correct
20 Correct 1 ms 464 KB Output is correct
21 Correct 1 ms 356 KB Output is correct
22 Correct 1 ms 464 KB Output is correct
23 Correct 0 ms 356 KB Output is correct
24 Correct 0 ms 356 KB Output is correct
25 Correct 0 ms 356 KB Output is correct
26 Correct 1 ms 352 KB Output is correct
27 Correct 1 ms 356 KB Output is correct
28 Correct 1 ms 356 KB Output is correct
29 Correct 1 ms 356 KB Output is correct
30 Correct 1 ms 356 KB Output is correct
31 Correct 4 ms 356 KB Output is correct
32 Correct 1 ms 356 KB Output is correct
33 Correct 0 ms 464 KB Output is correct
34 Correct 1 ms 356 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 344 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 3 ms 344 KB Output is correct
41 Correct 1 ms 344 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 1 ms 604 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 1 ms 344 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 3 ms 856 KB Output is correct
52 Correct 3 ms 860 KB Output is correct
53 Correct 363 ms 1604 KB Output is correct
54 Correct 393 ms 1624 KB Output is correct
55 Correct 1 ms 600 KB Output is correct
56 Correct 353 ms 1488 KB Output is correct
57 Correct 0 ms 344 KB Output is correct
58 Correct 72 ms 20940 KB Output is correct
59 Correct 70 ms 21124 KB Output is correct
60 Correct 45 ms 20648 KB Output is correct
61 Correct 61 ms 21376 KB Output is correct
62 Correct 46 ms 20480 KB Output is correct
63 Correct 61 ms 21124 KB Output is correct
64 Correct 1 ms 452 KB Output is correct
65 Correct 0 ms 348 KB Output is correct
66 Correct 0 ms 348 KB Output is correct
67 Correct 1 ms 452 KB Output is correct
68 Correct 0 ms 348 KB Output is correct
69 Correct 0 ms 348 KB Output is correct
70 Correct 0 ms 348 KB Output is correct
71 Correct 0 ms 348 KB Output is correct
72 Correct 0 ms 348 KB Output is correct
73 Correct 1 ms 604 KB Output is correct
74 Correct 0 ms 348 KB Output is correct
75 Correct 0 ms 348 KB Output is correct
76 Correct 200 ms 30860 KB Output is correct
77 Correct 178 ms 30544 KB Output is correct
78 Correct 184 ms 31052 KB Output is correct
79 Correct 156 ms 30112 KB Output is correct
80 Correct 164 ms 29892 KB Output is correct
81 Correct 270 ms 31220 KB Output is correct
82 Correct 269 ms 31196 KB Output is correct
83 Correct 1 ms 344 KB Output is correct
84 Correct 1 ms 348 KB Output is correct
85 Correct 0 ms 348 KB Output is correct
86 Correct 0 ms 456 KB Output is correct
87 Correct 1 ms 348 KB Output is correct
88 Correct 0 ms 348 KB Output is correct
89 Correct 1 ms 344 KB Output is correct
90 Correct 0 ms 348 KB Output is correct
91 Correct 0 ms 456 KB Output is correct
92 Correct 3 ms 348 KB Output is correct
93 Correct 0 ms 348 KB Output is correct
94 Correct 0 ms 348 KB Output is correct
95 Correct 0 ms 348 KB Output is correct
96 Correct 1 ms 348 KB Output is correct
97 Correct 1 ms 456 KB Output is correct
98 Correct 1 ms 348 KB Output is correct
99 Correct 0 ms 348 KB Output is correct
100 Correct 1 ms 344 KB Output is correct
101 Correct 3 ms 348 KB Output is correct
102 Correct 0 ms 348 KB Output is correct
103 Correct 773 ms 38320 KB Output is correct
104 Correct 428 ms 37596 KB Output is correct
105 Correct 417 ms 37616 KB Output is correct
106 Correct 215 ms 37116 KB Output is correct
107 Correct 204 ms 36788 KB Output is correct
108 Execution timed out 4016 ms 40572 KB Time limit exceeded
109 Halted 0 ms 0 KB -