Submission #857872

#TimeUsernameProblemLanguageResultExecution timeMemory
857872UmairAhmadMirzaPipes (CEOI15_pipes)C++17
20 / 100
5091 ms16596 KiB
//In the name of Allah the most beneficent, the most merciful. #include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast,unroll-loops") // #pragma GCC target("avx,avx2,avx512,fma") const int N = 5005; vector<int> adj[N]; int e1,e2; bool vis[N]; int n,m; void dfs(int node){ vis[node]=1; bool b=0; for(auto i:adj[node]){ if((b==0) && (((node==e1)&&(i==e2)) || ((node==e2)&&(i==e1)))){ b=1; continue; } if(vis[i]==0) dfs(i); } } bool check(pair<int,int> e){ e1=e.first; e2=e.second; for(int i=0;i<=n;i++) vis[i]=0; dfs(e1); return !(vis[e2]); } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>m; vector<pair<int,int>> ed; for(int i=0;i<m;i++){ int a,b; cin>>a>>b; adj[a].push_back(b); adj[b].push_back(a); ed.push_back({a,b}); } for(auto e:ed) if(check(e)) cout<<e.first<<' '<<e.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...