Submission #1041569

# Submission time Handle Problem Language Result Execution time Memory
1041569 2024-08-02T05:52:40 Z 정민찬(#11002) Brought Down the Grading Server? (CEOI23_balance) C++17
0 / 100
61 ms 37328 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;
        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';
    }

}
# Verdict Execution time Memory Grader output
1 Incorrect 2 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 8024 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 61 ms 37328 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 61 ms 37328 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 8024 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 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 15964 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 15964 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 61 ms 37328 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 61 ms 37328 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 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 -