# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
680263 | 2023-01-10T10:53:23 Z | peijar | Pipes (CEOI15_pipes) | C++17 | 1189 ms | 50660 KB |
#include <cstdio> #include <vector> using namespace std; #define pb push_back typedef pair<int,int> pp; int n, m; struct unf { int par[100010]; void init(){ for(int i=1; i<=n; ++i) par[i]=i; } int root(int x){ return (x==par[x])?x:(par[x]=root(par[x])); } bool merge(int a,int b){ a=root(a); b=root(b); if(a==b) return false; par[a]=b; return true; } } f1, f2; int par[100010]; int idx[100010]; int lowl[100010]; int nt; vector<int> edge[100010]; void dfs(int x){ idx[x] = lowl[x] = ++nt; bool cl = false; for(int y:edge[x]){ if(par[x] == y && !cl){ cl=true; continue; } if(!idx[y]){ par[y]=x; dfs(y); lowl[x] = min(lowl[x], lowl[y]); } else lowl[x] = min(lowl[x], idx[y]); } if(par[x] && idx[x]==lowl[x]) printf("%d %d\n", x, par[x]); } int main(){ scanf("%d%d", &n, &m); f1.init(); f2.init(); for(;m--;){ int a,b; scanf("%d%d", &a, &b); if(f1.merge(a,b) || f2.merge(a,b)) edge[a].pb(b), edge[b].pb(a); } for(int i=1; i<=n; ++i) if(par[i]==0) dfs(i); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2644 KB | Output is correct |
2 | Correct | 1 ms | 2644 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 3028 KB | Output is correct |
2 | Correct | 5 ms | 2900 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 104 ms | 2896 KB | Output is correct |
2 | Correct | 106 ms | 2800 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 193 ms | 3620 KB | Output is correct |
2 | Correct | 209 ms | 3216 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 304 ms | 5188 KB | Output is correct |
2 | Runtime error | 270 ms | 18916 KB | Memory limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 410 ms | 10100 KB | Output is correct |
2 | Runtime error | 422 ms | 25564 KB | Memory limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 599 ms | 11224 KB | Output is correct |
2 | Runtime error | 604 ms | 42084 KB | Memory limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 798 ms | 13500 KB | Output is correct |
2 | Runtime error | 787 ms | 50660 KB | Memory limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1002 ms | 17060 KB | Memory limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1189 ms | 29328 KB | Memory limit exceeded |
2 | Halted | 0 ms | 0 KB | - |