This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |