답안 #1041598

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1041598 2024-08-02T06:03:54 Z 정민찬(#11002) Brought Down the Grading Server? (CEOI23_balance) C++17
35 / 100
101 ms 23452 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

vector<pair<ll,ll>> adj[200010];
int cnt[200010];
int num[200010];
int ori[200010];
int vis[200010];

int main() {
    ios_base :: sync_with_stdio(false); cin.tie(NULL);
    ll N, S, T;
    cin >> N >> S >> T;
    vector<vector<ll>> a(N, vector<ll>(S));
    for (ll i=0; i<N; i++) {
        for (ll j=0; j<S; j++) {
            cin >> a[i][j];
        }
    }
    for (ll i=1; i<=T; i++) num[i] = i, ori[i] = i;
    int pv = T;
    for (ll i=0; i<N; i++) {
        vector<ll> node(S);
        for (ll j=0; j<S; j++) {
            if (cnt[num[a[i][j]]] == 2) {
                num[a[i][j]] = ++ pv;
                ori[num[a[i][j]]] = a[i][j];
            }
            cnt[num[a[i][j]]] ++;
            node[j] = num[a[i][j]];
        }
        adj[node[0]].push_back({node[1], i});
        adj[node[1]].push_back({node[0], i});
    }
    ll ppv = pv;
    for (ll i=1; i<=ppv; i++) {
        if (cnt[i] == 1) {
            if (ppv == pv || cnt[pv] == 2) pv ++;
            adj[pv].push_back({i, -1});
            adj[i].push_back({pv, -1});
            cnt[pv] ++;
        }
    }
    assert(cnt[pv] == 2);
    for (ll i=1; i<=pv; i++) {
        if (vis[i] || adj[i].empty()) continue;
        int p = -1;
        int x = i;
        vector<int> vtx, edg;
        while (true) {
            vtx.push_back(x);
            vis[x] = 1;
            if (adj[x][0].first == p) swap(adj[x][0], adj[x][1]);
            edg.push_back(adj[x][0].second);
            p = x;
            x = adj[x][0].first;
            if (x == i) break;
        }
        for (ll j=0; j<vtx.size(); j++) {
            if (edg[j] == -1) continue;
            if (a[edg[j]][0] != ori[vtx[j]]) {
                swap(a[edg[j]][0], a[edg[j]][1]);
            }
        }
    }
    for (ll i=0; i<N; i++) {
        for (ll j=0; j<S; j++) {
            cout << a[i][j] << ' ';
        }
        cout << '\n';
    }

}

Compilation message

balance.cpp: In function 'int main()':
balance.cpp:61:23: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |         for (ll j=0; j<vtx.size(); j++) {
      |                      ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8024 KB Correct
2 Runtime error 6 ms 15964 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8028 KB Correct
2 Correct 2 ms 8028 KB Correct
3 Correct 2 ms 8108 KB Correct
4 Correct 1 ms 8028 KB Correct
5 Correct 1 ms 8028 KB Correct
6 Correct 2 ms 8028 KB Correct
7 Correct 2 ms 8028 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 20128 KB Correct
2 Correct 66 ms 20196 KB Correct
3 Correct 38 ms 18708 KB Correct
4 Correct 51 ms 18736 KB Correct
5 Correct 77 ms 20088 KB Correct
6 Correct 86 ms 20260 KB Correct
7 Correct 66 ms 20052 KB Correct
8 Correct 39 ms 20340 KB Correct
9 Correct 43 ms 21324 KB Correct
10 Correct 57 ms 20584 KB Correct
11 Correct 39 ms 20552 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 20128 KB Correct
2 Correct 66 ms 20196 KB Correct
3 Correct 38 ms 18708 KB Correct
4 Correct 51 ms 18736 KB Correct
5 Correct 77 ms 20088 KB Correct
6 Correct 86 ms 20260 KB Correct
7 Correct 66 ms 20052 KB Correct
8 Correct 39 ms 20340 KB Correct
9 Correct 43 ms 21324 KB Correct
10 Correct 57 ms 20584 KB Correct
11 Correct 39 ms 20552 KB Correct
12 Correct 52 ms 20952 KB Correct
13 Correct 49 ms 20920 KB Correct
14 Correct 59 ms 18652 KB Correct
15 Correct 28 ms 19292 KB Correct
16 Correct 53 ms 20828 KB Correct
17 Correct 62 ms 20676 KB Correct
18 Correct 55 ms 20704 KB Correct
19 Correct 68 ms 20556 KB Correct
20 Correct 46 ms 21432 KB Correct
21 Correct 40 ms 20560 KB Correct
22 Correct 33 ms 20540 KB Correct
23 Correct 101 ms 23452 KB Correct
24 Correct 47 ms 19500 KB Correct
25 Correct 51 ms 21700 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8028 KB Correct
2 Correct 2 ms 8028 KB Correct
3 Correct 2 ms 8108 KB Correct
4 Correct 1 ms 8028 KB Correct
5 Correct 1 ms 8028 KB Correct
6 Correct 2 ms 8028 KB Correct
7 Correct 2 ms 8028 KB Correct
8 Correct 50 ms 20128 KB Correct
9 Correct 66 ms 20196 KB Correct
10 Correct 38 ms 18708 KB Correct
11 Correct 51 ms 18736 KB Correct
12 Correct 77 ms 20088 KB Correct
13 Correct 86 ms 20260 KB Correct
14 Correct 66 ms 20052 KB Correct
15 Correct 39 ms 20340 KB Correct
16 Correct 43 ms 21324 KB Correct
17 Correct 57 ms 20584 KB Correct
18 Correct 39 ms 20552 KB Correct
19 Correct 52 ms 20952 KB Correct
20 Correct 49 ms 20920 KB Correct
21 Correct 59 ms 18652 KB Correct
22 Correct 28 ms 19292 KB Correct
23 Correct 53 ms 20828 KB Correct
24 Correct 62 ms 20676 KB Correct
25 Correct 55 ms 20704 KB Correct
26 Correct 68 ms 20556 KB Correct
27 Correct 46 ms 21432 KB Correct
28 Correct 40 ms 20560 KB Correct
29 Correct 33 ms 20540 KB Correct
30 Correct 101 ms 23452 KB Correct
31 Correct 47 ms 19500 KB Correct
32 Correct 51 ms 21700 KB Correct
33 Correct 2 ms 8024 KB Correct
34 Correct 2 ms 8028 KB Correct
35 Correct 1 ms 8104 KB Correct
36 Correct 2 ms 8028 KB Correct
37 Correct 2 ms 8024 KB Correct
38 Correct 1 ms 8028 KB Correct
39 Correct 1 ms 8028 KB Correct
40 Correct 75 ms 20844 KB Correct
41 Correct 51 ms 20968 KB Correct
42 Correct 56 ms 19560 KB Correct
43 Correct 37 ms 19024 KB Correct
44 Correct 43 ms 21076 KB Correct
45 Correct 58 ms 21032 KB Correct
46 Correct 56 ms 20952 KB Correct
47 Correct 60 ms 20580 KB Correct
48 Correct 40 ms 21448 KB Correct
49 Correct 34 ms 20668 KB Correct
50 Correct 35 ms 20260 KB Correct
51 Correct 77 ms 23448 KB Correct
52 Correct 33 ms 19436 KB Correct
53 Correct 76 ms 21736 KB Correct
54 Correct 36 ms 16856 KB Correct
55 Correct 2 ms 8540 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 10 ms 15936 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 10 ms 15936 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 10 ms 15936 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 20128 KB Correct
2 Correct 66 ms 20196 KB Correct
3 Correct 38 ms 18708 KB Correct
4 Correct 51 ms 18736 KB Correct
5 Correct 77 ms 20088 KB Correct
6 Correct 86 ms 20260 KB Correct
7 Correct 66 ms 20052 KB Correct
8 Correct 39 ms 20340 KB Correct
9 Correct 43 ms 21324 KB Correct
10 Correct 57 ms 20584 KB Correct
11 Correct 39 ms 20552 KB Correct
12 Runtime error 10 ms 15936 KB Execution killed with signal 11
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 20128 KB Correct
2 Correct 66 ms 20196 KB Correct
3 Correct 38 ms 18708 KB Correct
4 Correct 51 ms 18736 KB Correct
5 Correct 77 ms 20088 KB Correct
6 Correct 86 ms 20260 KB Correct
7 Correct 66 ms 20052 KB Correct
8 Correct 39 ms 20340 KB Correct
9 Correct 43 ms 21324 KB Correct
10 Correct 57 ms 20584 KB Correct
11 Correct 39 ms 20552 KB Correct
12 Correct 52 ms 20952 KB Correct
13 Correct 49 ms 20920 KB Correct
14 Correct 59 ms 18652 KB Correct
15 Correct 28 ms 19292 KB Correct
16 Correct 53 ms 20828 KB Correct
17 Correct 62 ms 20676 KB Correct
18 Correct 55 ms 20704 KB Correct
19 Correct 68 ms 20556 KB Correct
20 Correct 46 ms 21432 KB Correct
21 Correct 40 ms 20560 KB Correct
22 Correct 33 ms 20540 KB Correct
23 Correct 101 ms 23452 KB Correct
24 Correct 47 ms 19500 KB Correct
25 Correct 51 ms 21700 KB Correct
26 Runtime error 10 ms 15936 KB Execution killed with signal 11
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8024 KB Correct
2 Runtime error 6 ms 15964 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -