답안 #54935

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
54935 2018-07-05T13:32:05 Z Diuven Pipes (CEOI15_pipes) C++11
10 / 100
3462 ms 65536 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=100010, inf=2e9;


int n, m;
int U[2][MX];

vector<int> G[MX];

int find(int t, int x){
    return x==U[t][x] ? x : U[t][x]=find(t,U[t][x]);
}
void unite(int t, int x, int y){
    if(find(t,x)==find(t,y)) return;
    U[t][U[t][y]]=U[t][x];
}

int up[MX], dep[MX], now;
void dfs(int v, int p){
    dep[v]=++now; up[v]=dep[v];
    for(int x:G[v]){
        if(x==p) continue;
        if(dep[x]>0) up[v]=min(up[v], dep[x]);
        else{
            dfs(x,v);
            up[v]=min(up[v], up[x]);
            if(up[x]>dep[v]) cout<<v<<' '<<x<<'\n';
        }
    }
    now--;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n>>m;
    for(int i=1; i<=n; i++) U[0][i]=U[1][i]=i;
    for(int i=1; i<=m; i++){
        int u, v; cin>>u>>v;
        if(find(0,u)==find(1,v)){
            if(find(1,u)==find(1,v)) continue;
            unite(1,u,v);
        }
        else unite(0,u,v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    for(int i=1; i<=n; i++)
        if(dep[i]==0) dfs(i,-1);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2688 KB Output is correct
2 Incorrect 7 ms 2660 KB Wrong number of edges
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 3328 KB Output is correct
2 Incorrect 7 ms 3072 KB Wrong number of edges
# 결과 실행 시간 메모리 Grader output
1 Correct 147 ms 10808 KB Output is correct
2 Correct 141 ms 10196 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 293 ms 14360 KB Output is correct
2 Runtime error 326 ms 18700 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 566 ms 25448 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 1056 ms 31824 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 1741 ms 53908 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 2592 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 2994 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 3462 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -