Submission #478324

# Submission time Handle Problem Language Result Execution time Memory
478324 2021-10-07T03:07:57 Z hjc4vr Pipes (CEOI15_pipes) C++14
0 / 100
1210 ms 65540 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
vector<int> adj[100005];
vector<pair<int,int>> ans;
int low[100005],depths[100005];

void dfs(int cur,int par){
    depths[cur] = depths[par] + 1;
    low[cur] = depths[cur];
//    cout << 1;
    for (auto it : adj[cur]){
        if (it!=par){
            if (depths[it]==-1){
                dfs(it,cur);
                low[cur] = min(low[cur],low[it]);
                if (low[it]>depths[cur]){
                    ans.push_back(make_pair(it,cur));
                }
                
            }else{
                low[cur] = min(low[cur],depths[it]);
            }
        }
    }
}


int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n,m;cin>>n>>m;
    fill(depths,depths+100005,-1);
//    cout << depths[1];
    for (int i=0;i<m;++i){
        int a,b;cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    for (int i=1;i<=n;++i){
        dfs(i,i);
    }
    for (auto it:ans){
        int a = it.first, b= it.second;
        if (a<b) swap(a,b);
        cout << b  << " " << a << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3408 KB Output is correct
2 Incorrect 2 ms 3408 KB Wrong number of edges
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4176 KB Output is correct
2 Incorrect 7 ms 3920 KB Wrong number of edges
# Verdict Execution time Memory Grader output
1 Runtime error 154 ms 24884 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 289 ms 35272 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 493 ms 62188 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 835 ms 65536 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1000 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1210 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1175 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1202 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -