Pagini recente » Cod sursa (job #1100995) | Cod sursa (job #2578987) | Cod sursa (job #3273837) | Cod sursa (job #908768) | Cod sursa (job #1414798)
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fs first
#define sc second
#define pob pop_back
#define pub push_back
#define eps 1E-7
#define sz(a) a.size()
#define count_one __builtin_popcount;
#define count_onell __builtin_popcountll;
#define fastIO ios_base::sync_with_stdio(false)
#define PI (acos(-1.0))
#define linf (1LL<<62)//>4e18
#define inf (0x7f7f7f7f)//>2e9
#ifndef ONLINE_JUDGE
ifstream fin("biconex.in");
ofstream fout("biconex.out");
#endif
const int MAXN = 100010;
int n, m;
int rnk[MAXN], low[MAXN];
vector<int> vec[MAXN];
vector<vector<int> > comp;
stack<pair<int, int> > stk;
void newComp(int tx, int ty) {
vector<int> c;
int x, y;
do {
x = stk.top().fs; y = stk.top().sc;
stk.pop();
c.pub(x); c.pub(y);
} while(tx != x || ty != y);
comp.pub(c);
}
void df(int nod, int fn, int val) {
rnk[nod] = low[nod] = val;
for(auto it : vec[nod]) if(it != fn) {
if(!rnk[it]) {
stk.push(mp(nod, it));
df(it, nod, val + 1);
low[nod] = min(low[nod], low[it]);
if(rnk[nod] <= low[it])
newComp(nod, it);
} else
low[nod] = min(low[nod], rnk[it]);
}
}
void read() {
int x, y;
fin >> n >> m;
while(m--) {
fin >> x >> y;
vec[x].pub(y);
vec[y].pub(x);
}
}
int main() {
read();
df(1, 0, 1);
fout << comp.size() << "\n";
for(auto it : comp) {
sort(it.begin(), it.end());
it.resize(distance(it.begin(), unique(it.begin(), it.end())));
for(auto jt : it)
fout << jt << " ";
fout << "\n";
}
return 0;
}