# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1035112 | 2024-07-26T04:58:34 Z | vjudge1 | Pipes (CEOI15_pipes) | C++14 | 799 ms | 65536 KB |
#include <iostream> #include <vector> using namespace std; const int N = 1e5+2; struct dsu { int e[N]; int find(int &x) { return e[x] < 0 ? x : e[x] = find(e[x]); } bool join(int a, int b) { a = find(a), b = find(b); if (a == b) return false; if (e[a] > e[b]) swap(a, b); e[a] += e[b]; e[b] = a; return true; } } d1, d2; vector<int> g[N]; int timer=0; void dfs(int at, int par) { d1.e[at]=d2.e[at]=++timer; for(int &to:g[at]) { if(to == par) { par+=N; continue; } if(d2.e[to]) { d1.e[at]=min(d1.e[at], d2.e[to]); } else { dfs(to, at); d1.e[at]=min(d1.e[at], d1.e[to]); } } if(par>N)par-=N; if(d1.e[at] == d2.e[at] and at!=par) { printf("%d %d\n", at, par); } } int n, m, u, v; int main() { srand(time(0)); scanf("%d %d", &n, &m); //nt u, v; for(int i = 1;i<N;i++)d1.e[i]=d2.e[i]=-1; for(int i = 0;i<m;i++) { scanf("%d %d", &u, &v); if((d1.join(u, v) || d2.join(u, v))) { g[u].push_back(v); g[v].push_back(u); } } for(int i = 1;i<N;i++)d1.e[i]=d2.e[i]=0; for(int i= 1;i<=n;i++) { if(!d1.e[i]) { dfs(i, i); } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 3420 KB | Output is correct |
2 | Correct | 1 ms | 3420 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 3748 KB | Output is correct |
2 | Correct | 3 ms | 3732 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 64 ms | 3688 KB | Output is correct |
2 | Correct | 67 ms | 3676 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 105 ms | 4180 KB | Output is correct |
2 | Correct | 122 ms | 3928 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 182 ms | 5460 KB | Output is correct |
2 | Correct | 154 ms | 5200 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 239 ms | 9552 KB | Output is correct |
2 | Correct | 210 ms | 6636 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 360 ms | 10576 KB | Output is correct |
2 | Correct | 347 ms | 8064 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 535 ms | 12112 KB | Output is correct |
2 | Correct | 465 ms | 8204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 627 ms | 12168 KB | Output is correct |
2 | Correct | 566 ms | 8016 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 734 ms | 11696 KB | Output is correct |
2 | Runtime error | 799 ms | 65536 KB | Memory limit exceeded |
3 | Halted | 0 ms | 0 KB | - |