#include #include #include #include #include #include using namespace std; const int N=5006; stack s; vector adj[N], arc[N], com[N], ans; int n, m, t, ind, T, sum; int dfn[N], low[N], id[N], in[N]; bool vs[N]; void tarjan(int u) { dfn[u]=low[u]=T++; s.push(u), vs[u]=1; int len=(int)adj[u].size(); for(int i=0; ilow[v]) low[u]=low[v]; } else if(vs[v] && low[u]>dfn[v]) low[u]=dfn[v]; } if(low[u]==dfn[u]) { for(int v; 1; ) { v=s.top(); s.pop(), vs[v]=0; id[v]=ind, com[ind].push_back(v); if(v==u) break; } ind++; } } void DFS(int u) { vs[u]=1; int len=(int)arc[u].size(); sum+=(int)com[u].size(); for(int i=0; i