Submission #876846

#TimeUsernameProblemLanguageResultExecution timeMemory
876846Hacv16Pipes (CEOI15_pipes)C++17
0 / 100
297 ms65536 KiB
#include <bits/stdc++.h> using namespace std; const int MAX = 2e6 + 15; const int INF = 0x3f3f3f3f; int n, m, pre[MAX], low[MAX], seen[MAX], timer; vector<int> adj[MAX]; vector<pair<int, int>> bridges; void dfs(int u, int p) { seen[u] = true; pre[u] = low[u] = ++timer; for(auto v : adj[u]) { if(v == p) continue; if(!seen[v]) { dfs(v, u); low[u] = min(low[u], low[v]); }else{ low[u] = min(low[u], pre[v]); } if(low[v] > pre[u]) bridges.emplace_back(u, v); } } int32_t main(void) { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; while(m--) { int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u); } for(int i = 1; i <= n; i++) if(!seen[i]) dfs(i, i); for(auto [u, v] : bridges) cout << u << ' ' << v << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...