Submission #128248

#TimeUsernameProblemLanguageResultExecution timeMemory
128248zeyad49Pipes (CEOI15_pipes)C++17
10 / 100
5032 ms64064 KiB
#include <bits/stdc++.h> using namespace std; const int N=5000; int n; int cnt[N][N]; bool visited[N]; void dfs(int u) { visited[u] = true; for (int v = 0; v < n; v++) if (cnt[u][v] > 0 && !visited[v]) dfs(v); } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(NULL); int m,u,v; cin>>n>>m; while (m-- > 0) { cin>>u>>v; u--; v--; cnt[u][v]++; cnt[v][u]++; } for (int u = 0; u < n; u++) for (int v = u + 1; v < n; v++) { if (cnt[u][v] != 1) continue; cnt[u][v] = cnt[v][u] = 0; for(int i=0;i<n;i++) visited[i]=false; dfs(u); if (!visited[v]) printf("%d %d\n", u + 1, v + 1); cnt[u][v] = cnt[v][u] = 1; } }
#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...