답안 #921689

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
921689 2024-02-04T09:04:04 Z vjudge1 Council (JOI23_council) C++17
41 / 100
4000 ms 41596 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<vector<int>> important;
    vector<int> res;
    for(auto x : dist){
        important.push_back({});
        res.push_back(0);
        for(int j = 0; j < m; j ++){
            cnt[j] -= x.fs[j];
            if(cnt[j] == n / 2)
                important[important.size() - 1].push_back(j);
            if(cnt[j] >= n / 2)
                res[res.size() - 1] ++;
            cnt[j] += x.fs[j];
        }
    }
    vector<int> ans(n);
    int j = 0;
    for(auto x : dist){
        int mn = res[j];
        for(auto y : dist){
            int nums = 0;
            if(y != x or p[x.ss].size() >= 2){
                for(auto k : important[j])
                    nums += y.fs[k];
                mn = min(mn, nums);
            }
        }
        for(auto y : p[x.ss])
            ans[y] = res[j] - mn;
        for(int j = 0; j < m; j ++)
            cnt[j] += x.fs[j];
        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)
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 512 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 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 348 KB Output is correct
9 Correct 4 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 4 ms 604 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 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 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 456 KB Output is correct
21 Correct 1 ms 712 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 460 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 4 ms 348 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 0 ms 456 KB Output is correct
34 Correct 0 ms 460 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 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 3 ms 344 KB Output is correct
41 Correct 0 ms 456 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 344 KB Output is correct
44 Correct 1 ms 344 KB Output is correct
45 Correct 1 ms 600 KB Output is correct
46 Correct 1 ms 344 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 512 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 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 348 KB Output is correct
9 Correct 4 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 4 ms 604 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 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 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 456 KB Output is correct
21 Correct 1 ms 712 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 460 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 4 ms 348 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 0 ms 456 KB Output is correct
34 Correct 0 ms 460 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 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 3 ms 344 KB Output is correct
41 Correct 0 ms 456 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 344 KB Output is correct
44 Correct 1 ms 344 KB Output is correct
45 Correct 1 ms 600 KB Output is correct
46 Correct 1 ms 344 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 3 ms 856 KB Output is correct
52 Correct 3 ms 856 KB Output is correct
53 Correct 346 ms 1628 KB Output is correct
54 Correct 373 ms 1916 KB Output is correct
55 Correct 1 ms 600 KB Output is correct
56 Correct 363 ms 1880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 58 ms 20936 KB Output is correct
3 Correct 56 ms 21100 KB Output is correct
4 Correct 47 ms 20424 KB Output is correct
5 Correct 81 ms 21312 KB Output is correct
6 Correct 58 ms 20376 KB Output is correct
7 Correct 65 ms 21124 KB Output is correct
8 Correct 1 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 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 2 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 58 ms 20936 KB Output is correct
3 Correct 56 ms 21100 KB Output is correct
4 Correct 47 ms 20424 KB Output is correct
5 Correct 81 ms 21312 KB Output is correct
6 Correct 58 ms 20376 KB Output is correct
7 Correct 65 ms 21124 KB Output is correct
8 Correct 1 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 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 2 ms 468 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 243 ms 31444 KB Output is correct
21 Correct 183 ms 30804 KB Output is correct
22 Correct 179 ms 30968 KB Output is correct
23 Correct 153 ms 30640 KB Output is correct
24 Correct 155 ms 30400 KB Output is correct
25 Correct 287 ms 31564 KB Output is correct
26 Correct 287 ms 31620 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 1 ms 344 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 3 ms 456 KB Output is correct
37 Correct 0 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 1 ms 344 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 1 ms 456 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 3 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 58 ms 20936 KB Output is correct
3 Correct 56 ms 21100 KB Output is correct
4 Correct 47 ms 20424 KB Output is correct
5 Correct 81 ms 21312 KB Output is correct
6 Correct 58 ms 20376 KB Output is correct
7 Correct 65 ms 21124 KB Output is correct
8 Correct 1 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 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 2 ms 468 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 243 ms 31444 KB Output is correct
21 Correct 183 ms 30804 KB Output is correct
22 Correct 179 ms 30968 KB Output is correct
23 Correct 153 ms 30640 KB Output is correct
24 Correct 155 ms 30400 KB Output is correct
25 Correct 287 ms 31564 KB Output is correct
26 Correct 287 ms 31620 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 1 ms 344 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 3 ms 456 KB Output is correct
37 Correct 0 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 1 ms 344 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 1 ms 456 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 3 ms 348 KB Output is correct
46 Correct 1 ms 344 KB Output is correct
47 Correct 787 ms 38968 KB Output is correct
48 Correct 418 ms 38148 KB Output is correct
49 Correct 407 ms 38304 KB Output is correct
50 Correct 209 ms 37688 KB Output is correct
51 Correct 204 ms 37468 KB Output is correct
52 Execution timed out 4046 ms 41596 KB Time limit exceeded
53 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 58 ms 20936 KB Output is correct
3 Correct 56 ms 21100 KB Output is correct
4 Correct 47 ms 20424 KB Output is correct
5 Correct 81 ms 21312 KB Output is correct
6 Correct 58 ms 20376 KB Output is correct
7 Correct 65 ms 21124 KB Output is correct
8 Correct 1 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 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 2 ms 468 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 243 ms 31444 KB Output is correct
21 Correct 183 ms 30804 KB Output is correct
22 Correct 179 ms 30968 KB Output is correct
23 Correct 153 ms 30640 KB Output is correct
24 Correct 155 ms 30400 KB Output is correct
25 Correct 287 ms 31564 KB Output is correct
26 Correct 287 ms 31620 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 1 ms 344 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 3 ms 456 KB Output is correct
37 Correct 0 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 1 ms 344 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 1 ms 456 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 3 ms 348 KB Output is correct
46 Correct 1 ms 344 KB Output is correct
47 Correct 787 ms 38968 KB Output is correct
48 Correct 418 ms 38148 KB Output is correct
49 Correct 407 ms 38304 KB Output is correct
50 Correct 209 ms 37688 KB Output is correct
51 Correct 204 ms 37468 KB Output is correct
52 Execution timed out 4046 ms 41596 KB Time limit exceeded
53 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 512 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 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 348 KB Output is correct
9 Correct 4 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 4 ms 604 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 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 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 456 KB Output is correct
21 Correct 1 ms 712 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 460 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 4 ms 348 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 0 ms 456 KB Output is correct
34 Correct 0 ms 460 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 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 3 ms 344 KB Output is correct
41 Correct 0 ms 456 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 344 KB Output is correct
44 Correct 1 ms 344 KB Output is correct
45 Correct 1 ms 600 KB Output is correct
46 Correct 1 ms 344 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 3 ms 856 KB Output is correct
52 Correct 3 ms 856 KB Output is correct
53 Correct 346 ms 1628 KB Output is correct
54 Correct 373 ms 1916 KB Output is correct
55 Correct 1 ms 600 KB Output is correct
56 Correct 363 ms 1880 KB Output is correct
57 Correct 0 ms 344 KB Output is correct
58 Correct 58 ms 20936 KB Output is correct
59 Correct 56 ms 21100 KB Output is correct
60 Correct 47 ms 20424 KB Output is correct
61 Correct 81 ms 21312 KB Output is correct
62 Correct 58 ms 20376 KB Output is correct
63 Correct 65 ms 21124 KB Output is correct
64 Correct 1 ms 348 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 348 KB Output is correct
68 Correct 0 ms 348 KB Output is correct
69 Correct 0 ms 348 KB Output is correct
70 Correct 1 ms 344 KB Output is correct
71 Correct 1 ms 348 KB Output is correct
72 Correct 1 ms 344 KB Output is correct
73 Correct 2 ms 468 KB Output is correct
74 Correct 1 ms 348 KB Output is correct
75 Correct 1 ms 348 KB Output is correct
76 Correct 243 ms 31444 KB Output is correct
77 Correct 183 ms 30804 KB Output is correct
78 Correct 179 ms 30968 KB Output is correct
79 Correct 153 ms 30640 KB Output is correct
80 Correct 155 ms 30400 KB Output is correct
81 Correct 287 ms 31564 KB Output is correct
82 Correct 287 ms 31620 KB Output is correct
83 Correct 1 ms 344 KB Output is correct
84 Correct 1 ms 348 KB Output is correct
85 Correct 1 ms 348 KB Output is correct
86 Correct 1 ms 348 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 348 KB Output is correct
90 Correct 1 ms 344 KB Output is correct
91 Correct 1 ms 348 KB Output is correct
92 Correct 3 ms 456 KB Output is correct
93 Correct 0 ms 600 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 344 KB Output is correct
97 Correct 0 ms 348 KB Output is correct
98 Correct 1 ms 456 KB Output is correct
99 Correct 0 ms 348 KB Output is correct
100 Correct 0 ms 348 KB Output is correct
101 Correct 3 ms 348 KB Output is correct
102 Correct 1 ms 344 KB Output is correct
103 Correct 787 ms 38968 KB Output is correct
104 Correct 418 ms 38148 KB Output is correct
105 Correct 407 ms 38304 KB Output is correct
106 Correct 209 ms 37688 KB Output is correct
107 Correct 204 ms 37468 KB Output is correct
108 Execution timed out 4046 ms 41596 KB Time limit exceeded
109 Halted 0 ms 0 KB -