using namespace std; const int MAXE = 300010; const int MAXP = 1010; struct N { int v,next; }edge[MAXE*2]; int head[MAXP]; int Top; int high[MAXP]; int low[MAXP]; int subnet[MAXP]; int dfsClock; void Link(int u,int v) { edge[Top].v = v; edge[Top].next = head[u]; head[u] = Top++; } void InitGraph() { dfsClock = 0; memset(high,0,sizeof(high)); memset(low,0,sizeof(low)); memset(subnet,0,sizeof(subnet)); memset(head,-1,sizeof(head)); Top = 0; } int dfs(int s,int pre)//dfs结束后,subnet[i]记录的为拿掉第i个点之后的联通分量的个数 { int lowu = high[s] = ++dfsClock; for(int p = head[s]; p != -1; p = edge[p].next) { if(high[edge[p].v] == 0) { int lowv = dfs(edge[p].v,s); lowu = min(lowu,lowv); if(lowv >= high[s]) subnet[s]++; } else if(high[edge[p].v] < high[s] && edge[p].v != pre) { lowu = min(lowu,high[edge[p].v]); } } if(pre != -1) subnet[s]++; low[s] = lowu; return lowu; }
时间: 2024-10-31 22:24:31