Submission #156322

#TimeUsernameProblemLanguageResultExecution timeMemory
156322AkashiPipes (CEOI15_pipes)C++14
10 / 100
3062 ms65540 KiB
#include <bits/stdc++.h> using namespace std; struct dsu{ int TT[100005]; void init(int n){ for(int i = 1; i <= n ; ++i) TT[i] = i; } void unite(int x, int y){TT[x] = y;} int find(int x){ int R = x; while(R != TT[R]) R = TT[R]; while(x != TT[x]){ int aux = TT[x]; TT[x] = R; x = aux; } return R; } }; dsu A, B; int n, m; int low[100005], h[100005]; bitset <100002> viz; vector <int> v[100005]; void tarjan(int nod, int papa = 0){ viz[nod] = 1; for(auto it : v[nod]){ if(papa == it) continue ; if(!viz[it]){ low[it] = h[it] = h[nod] + 1; tarjan(it, nod); low[nod] = min(low[nod], low[it]); if(low[it] > h[nod]) printf("%d %d\n", it, nod); } else low[nod] = min(h[it], low[nod]); } } int main() { scanf("%d%d", &n, &m); A.init(n); B.init(n); int x, y; for(int i = 1; i <= m ; ++i){ scanf("%d%d", &x, &y); if(A.find(x) != A.find(y)){ v[x].push_back(y); v[y].push_back(x); } else if(B.find(x) != B.find(y)){ v[x].push_back(y); v[y].push_back(x); } } for(int i = 1; i <= n ; ++i) if(!viz[i]) tarjan(i); return 0; }

Compilation message (stderr)

pipes.cpp: In function 'int main()':
pipes.cpp:50:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~
pipes.cpp:56:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &x, &y);
         ~~~~~^~~~~~~~~~~~~~~~
#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...