#include<bits/stdc++.h>
using namespace std;
namespace acac
{
struct edge
{
int to,ne,b;
}e[600010];
int H[600010];
struct node
{
int dfn,low,b;
}tree[100010];
int num,tf=0,cnt,bsum=1,root,lt;
void tarjan(int u,int f)
{
tree[u].dfn=tree[u].low=++cnt;
int s=0;
for(int i=H[u];i;i=e[i].ne)
{
int v=e[i].to;
if(!tree[v].dfn)
{
s++;
tarjan(v,u);
tree[u].low=min(tree[u].low,tree[v].low);
if(tree[v].low>tree[u].dfn&&!tf)
{
cout<<0<<'\n';
tf=1;
}
}
else if(v!=f)
{
tree[u].low=min(tree[v].dfn,tree[u].low);
}
}
}
void add(int a,int b)
{
e[++bsum].to=b;
e[bsum].ne=H[a];
H[a]=bsum;
return ;
}
void dfs(int u,int f)
{
tree[u].b=++cnt;
for(int i=H[u];i;i=e[i].ne)
{
int v=e[i].to;
if(!tree[v].b)
{
e[i].b=e[i^1].b=1;
cout<<u<<" "<<v<<'\n';
dfs(v,u);
}
else if(v!=f&&tree[v].b<tree[u].b&&!e[i].b)
{
e[i].b=e[i^1].b=1;
cout<<u<<" "<<v<<'\n';
}
}
}
int main()
{
int n,m;
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++)
{
int a,b;
scanf("%d%d",&a,&b);
add(a,b);
add(b,a);
}
tarjan(1,0);
cnt=0;
if(!tf)dfs(1,0);
return 0;
}
}
int main()
{
acac::main();
return 0;
}
1605B - Reverse Sort | 1607C - Minimum Extraction |
1604B - XOR Specia-LIS-t | 1606B - Update Files |
1598B - Groups | 1602B - Divine Array |
1594B - Special Numbers | 1614A - Divan and a Store |
2085. Count Common Words With One Occurrence | 2089. Find Target Indices After Sorting Array |
2090. K Radius Subarray Averages | 2091. Removing Minimum and Maximum From Array |
6. Zigzag Conversion | 1612B - Special Permutation |
1481. Least Number of Unique Integers after K Removals | 1035. Uncrossed Lines |
328. Odd Even Linked List | 1219. Path with Maximum Gold |
1268. Search Suggestions System | 841. Keys and Rooms |
152. Maximum Product Subarray | 337. House Robber III |
869. Reordered Power of 2 | 1593C - Save More Mice |
1217. Minimum Cost to Move Chips to The Same Position | 347. Top K Frequent Elements |
1503. Last Moment Before All Ants Fall Out of a Plank | 430. Flatten a Multilevel Doubly Linked List |
1290. Convert Binary Number in a Linked List to Integer | 1525. Number of Good Ways to Split a String |