Pagini recente » Cod sursa (job #2440522) | Cod sursa (job #184137) | Cod sursa (job #1953972) | Cod sursa (job #1463165) | Cod sursa (job #1868027)
#include <bits/stdc++.h>
using namespace std;
ifstream f("biconex.in");
ofstream g("biconex.out");
int n,m,i,j,comp,k,x,y,L[1<<17],S[1<<17],LL[1<<17];
vector <int> V[1<<17],Sol[1<<17];
void dfs(int x)
{
S[++k]=x;
for(auto it : V[x])
if(!L[it])
{
int ck=k;
L[it]=LL[it]=LL[x]+1;
dfs(it);
L[x]=min(L[x],L[it]);
if(L[it]>=LL[x])
{
++comp;
while(k>ck) Sol[comp].push_back(S[k--]);
Sol[comp].push_back(x);
}
}
else L[x]=min(L[x],LL[it]);
}
int main()
{
f>>n>>m;
while(m--)
{
f>>x>>y;
V[x].push_back(y);
V[y].push_back(x);
}
L[1]=LL[1]=1;
dfs(1);
g<<comp<<'\n';
for(i=1;i<=comp;++i,g<<'\n')
for(auto it : Sol[i]) g<<it<<' ';
return 0;
}