I think it's a lot easier than a double-connected Tarjan. The thought and the double connected component are the same pattern.
#include <cstdio> #include <cstring> #include <cstdlib> #include <stack>using namespace std; const int N = 1e5;int Dfn[n], Scc_id[n];int deep, scc_cnt;stack <int> s;int dfs (int u) {int Lowu = Dfn[u] = ++dee P S.push (U); for (int i = head[u]; ~i; i = e[i].next) {int v = E[I].V; if (!dfn[v]) {int LOWV = DFS (v); Lowu = min (Lowu, LOWV); } else if (!scc_id[v]) {///attached to the stack are not yet labeled ancestors Lowu = Min (Lowu, dfn[v]); }//uses the points in the current SCC to update} if (Lowu = = Dfn[u]) {//Only the points first found satisfy this condition scc_cnt++; while (1) {int x = S.top (); S.pop (); SCC_ID[X] = scc_cnt; if (x = = u) break; }} return Lowu;} void Tarjan () {for (int i = 0; i < n; i++) {dfn[i] = scc_id[i] = 0; } deep = scc_cnt = 0; for (int i = 0; i < n; i++) {if (!dfn[i]) DFS (i); }}int Main () {return 0;}
Strong connectivity strong connectivity template Tarjan