int dfn[maxn], low[maxn], num; stack<int> S; voidtarjan(int u, int fa){ staticint cnt = 0; dfn[u] = low[u] = ++cnt; S.push(u); for (int i = head[u]; ~i; i = e[i].next) { int v = e[i].to; if (v == fa) continue; if (!dfn[v]) { tarjan(v, u); low[u] = min(low[u], low[v]); if (low[v] >= dfn[u]) { ++num; int t; do { t = S.top(); S.pop(); Add_Edge(t, num); } while (t != v); Add_Edge(u, num); } } else low[u] = min(low[u], dfn[v]); } }