Submission #1041575

# Submission time Handle Problem Language Result Execution time Memory
1041575 2024-08-02T05:55:40 Z 정민찬(#11002) Brought Down the Grading Server? (CEOI23_balance) C++17
0 / 100
59 ms 37460 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]) continue;
        int p = -1;
        int x = i;
        vector<int> vtx, edg;
        assert(adj[i].size() == 2);
        /*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:49:13: warning: unused variable 'p' [-Wunused-variable]
   49 |         int p = -1;
      |             ^
balance.cpp:50:13: warning: unused variable 'x' [-Wunused-variable]
   50 |         int x = i;
      |             ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 8028 KB maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 8028 KB maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 59 ms 37460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 59 ms 37460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 8028 KB maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 15964 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 15964 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 15964 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 59 ms 37460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 59 ms 37460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 8028 KB maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one
2 Halted 0 ms 0 KB -