# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
154226 | 2019-09-19T11:41:47 Z | arnold518 | Pipes (CEOI15_pipes) | C++14 | 3258 ms | 65540 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 1e5; struct UF { int par[MAXN+10]; UF() { for(int i=0; i<=MAXN; i++) par[i]=i; } int Find(int x) { if(x==par[x]) return x; return par[x]=Find(par[x]); } void Union(int x, int y) { x=Find(x); y=Find(y); par[x]=y; } }; UF uf1, uf2; int N, M; vector<int> adj[MAXN+10]; int idx[MAXN+10], cnt=1; int dfs(int now, int bef) { idx[now]=cnt++; int ret=idx[now]; int k=0; for(int nxt : adj[now]) { if(nxt==bef) { k++; continue; } if(idx[nxt]!=0) ret=min(ret, idx[nxt]); else { int t=dfs(nxt, now); ret=min(ret, t); if(t>idx[now]) printf("%d %d\n", now, nxt); } } if(k>1) ret=min(ret, idx[bef]); return ret; } int main() { int i, j; scanf("%d%d", &N, &M); while(M--) { int u, v; scanf("%d%d", &u, &v); adj[u].push_back(v); adj[v].push_back(u); //if(uf1.Find(u)!=uf1.Find(v)) uf1.Union(u, v), adj[u].push_back(v), adj[v].push_back(u); //else if(uf2.Find(u)!=uf2.Find(v)) uf2.Union(u, v), adj[u].push_back(v), adj[v].push_back(u); } for(i=1; i<=N; i++) if(idx[i]==0) dfs(i, i); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 3576 KB | Output is correct |
2 | Correct | 5 ms | 3448 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 4120 KB | Output is correct |
2 | Correct | 22 ms | 3832 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 186 ms | 11804 KB | Output is correct |
2 | Correct | 180 ms | 11120 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 341 ms | 14968 KB | Output is correct |
2 | Runtime error | 414 ms | 19632 KB | Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 643 ms | 25796 KB | Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1016 ms | 30912 KB | Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1680 ms | 52664 KB | Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 2282 ms | 65540 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 2915 ms | 65540 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 3258 ms | 65540 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |