标签:
#include <iostream> #include <map> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <vector> #include <queue> #include <set> #define LL long long #define INF 0x3f3f3f3f #define Mod 1000000007 #define Seed1 31 #define Seed2 37 #define EPS (1e-8) using namespace std; const int MAXE = 300010; const int MAXP = 1010; struct N { int v,next; bool isbridge; }edge[MAXE*2]; int head[MAXP]; int Top; int high[MAXP]; int low[MAXP]; int dfsClock; void Link(int u,int v) { edge[Top].v = v; edge[Top].next = head[u]; edge[Top].isbridge = false; head[u] = Top++; } void InitGraph() { dfsClock = 0; memset(high,0,sizeof(high)); memset(low,0,sizeof(low)); memset(head,-1,sizeof(head)); Top = 0; } int dfs(int s,int pre) { 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,p); lowu = min(lowu,lowv); if(lowv == high[edge[p].v]) { edge[p].isbridge = true; edge[p^1].isbridge = true; } } else if(high[edge[p].v] < high[s] && (p^1) != pre) { lowu = min(lowu,high[edge[p].v]); } } low[s] = lowu; return lowu; }
标签:
原文地址:http://blog.csdn.net/zmx354/article/details/45745951