Submission #1084678

#TimeUsernameProblemLanguageResultExecution timeMemory
1084678SulAPipes (CEOI15_pipes)C++17
10 / 100
1033 ms65536 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <random> using namespace std; using namespace __gnu_pbds; #define bitcount __builtin_popcountll vector<int> adj[100000]; vector<pair<int,int>> bridges; int dep[100000], low[100000]; void dfs(int u, int p) { low[u] = dep[u] = dep[p] + 1; for (int ch : adj[u]) { if (ch == p) continue; if (dep[ch] == 0) { // tree edge dfs(ch, u); low[u] = min(low[u], low[ch]); } else { // back edge low[u] = min(low[u], dep[ch]); } } if (low[u] == dep[u] && u != p) { bridges.emplace_back(u+1, p+1); } } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n,m; cin >> n >> m; while (m--) { int a,b; cin >> a >> b; adj[--a].push_back(--b); adj[b].push_back(a); } for (int i = 0; i < n; i++) if (dep[i] == 0) { dfs(i, i); } for (auto [a, b] : bridges) { cout << a << " " << b << "\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...