Submission #478327

# Submission time Handle Problem Language Result Execution time Memory
478327 2021-10-07T03:28:18 Z hjc4vr Pipes (CEOI15_pipes) C++14
0 / 100
1219 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){
        if (depths[i]==-1)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 3404 KB Output is correct
2 Incorrect 2 ms 3404 KB Wrong number of edges
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4156 KB Output is correct
2 Incorrect 5 ms 3788 KB Wrong number of edges
# Verdict Execution time Memory Grader output
1 Runtime error 131 ms 19264 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 258 ms 25680 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 456 ms 46148 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 805 ms 62212 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 990 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1182 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1195 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1219 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -