# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
97155 | 2019-02-14T07:21:04 Z | dndhk | Pipes (CEOI15_pipes) | C++14 | 49 ms | 11512 KB |
#include <iostream> #include <vector> #include <stdio.h> #include <algorithm> #define MAX_N 100000 using namespace std; int N, M; pair<int, int> gp[MAX_N*4+1]; int sz = 0; int g1[MAX_N+1], g2[MAX_N+1]; int up[MAX_N+1], lv[MAX_N+1], p[MAX_N+1]; int v[MAX_N+1]; int sz2; int a, b, A, B; int s, e, m; void dfs(int x){ bool tf = true; up[x] = lv[x]; s = 0, e = sz-1; while(s<e){ m = (s+e)/2; if(gp[m].first<x) s = m+1; else e = m; } for(int i=s; i<sz; i++){ if(gp[i].first!=x) break; if(gp[i].second==p[x] && tf){ tf = false; continue; } if(lv[gp[i].second]!=0){ up[x] = min(up[x], lv[gp[i].second]); }else{ p[gp[i].second] = x; lv[gp[i].second] = lv[x]+1; dfs(gp[i].second); if(up[gp[i].second]>lv[x]) printf("%d %d\n", gp[i].second, x); up[x] = min(up[x], up[gp[i].second]); } } } int main(){ scanf("%d %d", &N, &M); for(int i=1; i<=N; i++) g1[i] = g2[i] = i; while(M--){ scanf("%d%d", &a, &b); A = a; while(g1[A]!=A){ v[sz2++] = A; A = g1[A]; } while(sz2>0){ g1[v[--sz2]] = A; } B = b; while(g1[B]!=B){ v[sz2++] = B; B = g1[B]; } while(sz2>0){ g1[v[--sz2]] = B; } if(A!=B){ gp[sz++] = {a, b}; gp[sz++] = {b, a}; g1[A] = B; continue; } A = a; B = b; while(g2[A]!=A){ v[sz2++] = A; } while(sz2>0){ g2[v[--sz2]] = A; } while(g2[B]!=B){ v[sz2++] = B; } while(sz2>0){ g2[v[--sz2]] = B; } if(A!=B){ gp[sz++] = {a, b}; gp[sz++] = {b, a};; g2[A] = B; } }sort(gp, gp+sz); for(int i=1; i<=N; i++){ if(lv[i]==0){ lv[i] = 1; dfs(i); } } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 13 ms | 11392 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 14 ms | 11512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 12 ms | 11392 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 13 ms | 11392 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 15 ms | 11392 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 22 ms | 11512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 23 ms | 11384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 28 ms | 11356 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 49 ms | 11340 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 28 ms | 11436 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |