# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
54891 | 2018-07-05T09:03:57 Z | 김세빈(#1509) | Pipes (CEOI15_pipes) | C++11 | 1799 ms | 7940 KB |
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> pii; vector <int> V[101010]; int P[101010], K[101010]; int R[101010], D[101010], S[101010]; bool chk[101010]; int n, m; void reorder(int x, int p, int r, int f) { int i, c; D[p] = D[r] + 1; R[p] = x; c = K[p], K[p] = r; if(c != r) chk[p] = f; if(chk[p]) P[p] = P[K[p]]; else P[p] = r; for(auto t: V[p]){ if(t != r){ if(t == c) reorder(x, t, p, chk[p]); else reorder(x, t, p, 0); } } } int color(int a, int b) { if(a == b) return a; if(D[a] > D[b]) chk[a] = 1, P[a] = color(P[a], b); else chk[b] = 1, P[b] = color(a, P[b]); } int main() { int i, a, b; scanf("%d%d", &n, &m); for(i=1;i<=n;i++){ S[i] = 1; R[i] = i; } for(i=1;i<=m;i++){ scanf("%d%d", &a, &b); if(R[a] != R[b]){ if(S[R[a]] > S[R[b]]) swap(a, b); V[a].push_back(b); V[b].push_back(a); S[R[b]] += S[R[a]]; reorder(R[b], a, b, 0); } else color(a, b); } for(i=1;i<=n;i++){ if(R[i] != i && !chk[i]) printf("%d %d\n", i, K[i]); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2688 KB | Output is correct |
2 | Incorrect | 4 ms | 2688 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 2944 KB | Output is correct |
2 | Incorrect | 7 ms | 2944 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 123 ms | 2860 KB | Output is correct |
2 | Incorrect | 120 ms | 2936 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 216 ms | 3200 KB | Output is correct |
2 | Incorrect | 248 ms | 3200 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 364 ms | 3992 KB | Output is correct |
2 | Correct | 326 ms | 4280 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 545 ms | 6404 KB | Output is correct |
2 | Incorrect | 500 ms | 6384 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 836 ms | 6860 KB | Output is correct |
2 | Correct | 747 ms | 6796 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1178 ms | 7876 KB | Output is correct |
2 | Incorrect | 1144 ms | 7940 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1411 ms | 7800 KB | Output is correct |
2 | Incorrect | 1461 ms | 7940 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1799 ms | 7528 KB | Output is correct |
2 | Correct | 1616 ms | 7900 KB | Output is correct |