Submission #872927

#TimeUsernameProblemLanguageResultExecution timeMemory
872927Ghulam_JunaidPipes (CEOI15_pipes)C++17
20 / 100
5086 ms65536 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n, m; vector<pair<int, int>> edges, g[N]; bool vis[N]; void dfs(int v, int id){ vis[v] = 1; for (auto [u, x] : g[v]){ if (x == id or vis[u]) continue; dfs(u, id); } } int main(){ int n, m; cin >> n >> m; for (int i = 0; i < m; i++){ int u, v; cin >> u >> v; g[u].push_back({v, i}); g[v].push_back({u, i}); edges.push_back({u, v}); } int orig = 0; for (int v = 1; v <= n; v++){ if (!vis[v]){ orig++; dfs(v, m); } } for (int i=0; i<m; i++){ int cc = 0; for (int v = 1; v <= n; v++) vis[v] = 0; for (int v = 1; v <= n; v++){ if (!vis[v]){ cc++; dfs(v, i); } } if (cc != orig) cout << edges[i].first << " " << edges[i].second << endl; } }
#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...