Submission #760822

# Submission time Handle Problem Language Result Execution time Memory
760822 2023-06-18T15:26:59 Z a_aguilo Pipes (CEOI15_pipes) C++14
10 / 100
2957 ms 65536 KB
#include<bits/stdc++.h>

using namespace std;

vector<vector<int>> AdjList;
vector<int> lowlink, order;
vector<pair<int, int>> bridges;
int N, M, cnt;

void dfs (int node, int padre = -1){
    if(padre == -1){
        order[node] = 0;
        lowlink[node] = 0;
        for (int son: AdjList[node]){
            if(order[son] != -1) continue;
            cnt++;
            order[son] = cnt;
            dfs(son, node);
            if(lowlink[son] > order[node]) bridges.push_back({node, son});
        }
    }
    else{
        lowlink[node] = order[node];
        for (int son: AdjList[node]){
            if(son == padre) continue;
            if(order[son] != -1){
                lowlink[node] = min(lowlink[node], lowlink[son]);
                continue;
            }
            cnt++;
            order[son] = cnt;
            dfs(son, node);
            if(lowlink[son] > order[node]) bridges.push_back({node, son});
            if(lowlink[son] < order[node]){
                lowlink[node] = min(lowlink[node], lowlink[son]);
            }
        }
    }
}

int main(){
    cnt = 0;
    cin >> N >> M;
    AdjList = vector<vector<int>>(N);
    lowlink = vector<int>(N);
    order = vector<int>(N, -1);
    int u, v;
    for(int i = 0; i < M; ++i){
        cin >> u >> v; u--; v--;
        AdjList[u].push_back(v);
        AdjList[v].push_back(u);
    }
    for(int i = 0; i < N; ++i){
    	if(order[i] == -1) dfs(i);
    }
    for(pair<int, int> path: bridges) cout << path.first + 1 << " " << path.second + 1 << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 980 KB Output is correct
2 Incorrect 6 ms 724 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 233 ms 13936 KB Output is correct
2 Correct 224 ms 13164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 408 ms 21732 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 708 ms 39640 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 961 ms 51316 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1609 ms 65536 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2119 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2649 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2957 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -