Pagini recente » Cod sursa (job #1512410) | Cod sursa (job #2695602) | Cod sursa (job #1872415) | Cod sursa (job #2739327) | Cod sursa (job #1479510)
#include <bits/stdc++.h>
#define MOD 1000000007
#define Nmax 100005
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define eps 0.000000000001
using namespace std;
ofstream fout("biconex.out");
int n,nr,cnt[Nmax],Low[Nmax],Niv[Nmax],St[Nmax],top;
long long sol;
bool viz[Nmax];
vector <int> L[Nmax],B[Nmax],Tree[Nmax];
inline void Dfs(int nod, int tata, int lvl)
{
Niv[nod]=Low[nod]=lvl; viz[nod]=true; St[++top]=nod;
for(auto it : L[nod])
{
if(it==tata) continue;
if(viz[it]) Low[nod]=min(Low[nod],Niv[it]);
else
{
Dfs(it,nod,lvl+1);
Low[nod]=min(Low[nod],Low[it]);
if(Low[it]>=Niv[nod])
{
++nr;
for(;top && St[top]!=it;B[nr].pb(St[top--]));
B[nr].pb(St[top--]); B[nr].pb(nod);
}
}
}
}
inline void Solve_Arbore()
{
fout<<nr<<"\n";
for(int i=1;i<=nr;++i)
{
for(auto it : B[i]) fout<<it<<" ";
fout<<"\n";
}
}
int main()
{
int i,j,m,x,y;
/*#ifndef ONLINE_JUDGE
freopen ("date.in","r",stdin);
freopen ("date.out","w",stdout);
#endif*/
//cin.sync_with_stdio(0);
ifstream cin("biconex.in");
cin>>n>>m;
while(m--)
{
cin>>x>>y;
L[x].pb(y); L[y].pb(x);
}
Dfs(1,0,1);
Solve_Arbore();
//cout<<sol;
return 0;
}