# [图论] 求点双联通分量

## 代码

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>

using namespace std;
const int MAXN = 100000 + 10;
const int MAXM = 200000 + 10;

int Head[MAXN], to[MAXM], Next[MAXM], tot = 1;
int dfn[MAXN], low[MAXN], time_stamp;

stack <pair<int, int> > Sta;

int bccNo[MAXN], bcc_cnt;
vector <int> bcc[MAXN];

int n, m;

inline void add(int a, int b){
to[tot] = b;
}

inline void dfs(int x, int f){
low[x] = dfn[x] = ++time_stamp;

int v = to[i];

if(!dfn[v]){
Sta.push(make_pair(x, v));

dfs(v, x);

low[x] = min(low[x], low[v]);

if(low[v] >= dfn[x]){
bcc_cnt++;

while(true){
pair<int, int> P = Sta.top();
Sta.pop();

if(bccNo[P.first] != bcc_cnt){
bcc[bcc_cnt].push_back(P.first);
bccNo[P.first] = bcc_cnt;
}

if(bccNo[P.second] != bcc_cnt){
bcc[bcc_cnt].push_back(P.second);
bccNo[P.second] = bcc_cnt;
}

if(P.first == x && P.second == v)
break;

}
}
}else if(dfn[v] < dfn[x] && v != f){
Sta.push(make_pair(x, v));
low[x] = min(low[x], dfn[v]);
}
}
}

inline void find_bcc(){
for(register int i=1; i<=n; i++){
if(!dfn[i])
dfs(i, 0);
}
}