# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
167280 | 2019-12-07T07:52:40 Z | mhy908 | Pipes (CEOI15_pipes) | C++14 | 71 ms | 65540 KB |
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define F first #define S second using namespace std; typedef long long LL; typedef pair<int, int> pii; typedef pair<LL, LL> pll; struct UNION_FIND{ int par[100010]; UNION_FIND(){for(int i=1; i<=100000; i++)par[i]=i;} int findpar(int num){return num==par[num]?num:par[num]=findpar(par[num]);} void mergepar(int a, int b){par[findpar(a)]=findpar(b);} bool query(int a, int b){return findpar(a)==findpar(b);} }uf1, uf2; stack<int> link[100010]; int n, m; int disc[100010], lowlink[100010], par[100010], t; void dfs(int u) { disc[u]=lowlink[u]=++t; bool temp=false; int m=link[u].size(); for(int i=1; i<=m; i++){ int v=link[u].top(); link[u].pop(); if(v==par[u]&&!temp)temp=true; else{ if(!disc[v]){ par[v]=u; dfs(v); if(lowlink[v]>disc[u])printf("%d %d\n", u, v); lowlink[u]=min(lowlink[u], lowlink[v]); } else lowlink[u]=min(lowlink[u], disc[v]); } } } int main() { scanf("%d %d", &n, &m); for(int i=1; i<=m; i++){ int u, v; scanf("%d %d", &u, &v); if(!uf1.query(u, v)){ uf1.mergepar(u, v); link[u].push(v); link[v].push(u); } else if(!uf2.query(u, v)){ uf2.mergepar(u, v); link[u].push(v); link[v].push(u); } } for(int i=1; i<=n; i++){ if(!disc[i])dfs(i); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 71 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 | 67 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 | 67 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 | 67 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 67 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 | 66 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 | 64 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 | 71 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 | 67 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 | 62 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |