제출 #156332

#제출 시각아이디문제언어결과실행 시간메모리
156332AkashiPipes (CEOI15_pipes)C++14
100 / 100
1801 ms14028 KiB
#include <bits/stdc++.h> using namespace std; struct dsu{ int R, aux, TT[100001]; 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){ R = x; while(R != TT[R]) R = TT[R]; while(x != TT[x]){ aux = TT[x]; TT[x] = R; x = aux; } return R; } }; dsu A, B; int n, m; int low[100001], h[100001]; bitset <100001> viz; vector <int> v[100001]; void tarjan(int nod, int papa = 0){ viz[nod] = 1; int cnt = 0; for(auto it : v[nod]){ if(papa == it){ ++cnt; continue ; } if(!viz[it]){ low[it] = h[nod] + 1; 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]); } if(cnt > 1) low[nod] = min(low[nod], h[nod] - 1); } int main() { scanf("%d%d", &n, &m); A.init(n); B.init(n); int x, y; while(m--){ scanf("%d%d", &x, &y); if(A.find(x) != A.find(y)){ v[x].push_back(y); v[y].push_back(x); A.unite(A.find(x), A.find(y)); } else if(B.find(x) != B.find(y)){ v[x].push_back(y); v[y].push_back(x); B.unite(B.find(x), B.find(y)); } } for(int i = 1; i <= n ; ++i) if(!viz[i]) tarjan(i); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

pipes.cpp: In function 'int main()':
pipes.cpp:56: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:62: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...