Submission #573358

#TimeUsernameProblemLanguageResultExecution timeMemory
573358vladislav11Pipes (CEOI15_pipes)C++14
0 / 100
1715 ms65536 KiB
#include <bits/stdc++.h> using namespace std; int n, m; vector< vector<int> > grp; vector<int> a, used; void dfs ( int v, int p ) { used[v] = 1; for ( auto& to : grp[v] ) if ( to != p ) { if ( used[to] ) { a[v]++; a[to]--; } else { dfs( to, v ); a[v] += a[to]; if ( !a[to] ) cout << v << ' ' << to << '\n'; } } return; } int main () { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; grp.assign( n+1, vector<int>() ); for ( int i=0; i<m; i++ ) { int u, v; cin >> u >> v; grp[u].push_back( v ); grp[v].push_back( u ); } a.assign( n+1, 0 ); used.assign( n+1, 0 ); for ( int i=1; i<=n; i++ ) if ( !used[i] ) dfs( i, -1 ); return 0; }
#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...