Submission #715708

#TimeUsernameProblemLanguageResultExecution timeMemory
715708stevancvPipes (CEOI15_pipes)C++14
20 / 100
743 ms65536 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double #define sp ' ' #define en '\n' #define smin(a, b) a = min(a, b) #define smax(a, b) a = max(a, b) using namespace std; const int N = 1e5 + 2; const int inf = 1e9; vector<pair<int, int>> g[N]; int dep[N]; vector<int> ans; int Dfs(int s, int e) { int d = dep[s]; for (auto u : g[s]) { if (u.second == e) continue; int v = u.first; if (dep[v] == inf) { dep[v] = dep[s] + 1; int x = Dfs(v, u.second); if (x == dep[v]) ans.push_back(u.second); else smin(d, x); } else smin(d, dep[v]); } return d; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; vector<int> u(m), v(m); for (int i = 0; i < m; i++) { cin >> u[i] >> v[i]; g[u[i]].push_back({v[i], i}); g[v[i]].push_back({u[i], i}); } for (int i = 1; i <= n; i++) dep[i] = inf; for (int i = 1; i <= n; i++) { if (dep[i] == inf) { dep[i] = 0; Dfs(i, -1); } } for (int i : ans) cout << u[i] << sp << v[i] << en; return 0; }
#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...