Submission #876850

#TimeUsernameProblemLanguageResultExecution timeMemory
876850Hacv16Pipes (CEOI15_pipes)C++17
10 / 100
172 ms27948 KiB
#include <bits/stdc++.h> using namespace std; const int MAX = 10010; const int INF = 0x3f3f3f3f; int n, m, pre[MAX], low[MAX], timer; bool seen[MAX]; 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...