Reprint Please specify source: http://blog.csdn.net/vmurder/article/details/42671865
In fact, I just feel that the original traffic is a bit more uncomfortable than unauthorized piracy 233 ...
Test instructions: Ask what points are cut points, cut off after the picture can be divided into several pieces.
Too much water does not want to be solved.
Tarjan is good, do not understand the code.
Code:
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define N 1005using namespace Std;int map[n][n];bool exist[n];int dfn[n],low[n],cnt;int stk[n],top;int d[n];void init () {memset (d , 0,sizeof (d)); Memset (Dfn,0,sizeof (DFN)); memset (map,0,sizeof (map)); memset (exist,0,sizeof (exist)); cnt=top=0;} void Tarjan (int x,int p) {int v,temp;dfn[x]=low[x]=++cnt,stk[++top]=x;for (v=1;v<=1000;v++) if (map[x][v]&& V!=P) {if (!dfn[v]) {Tarjan (v,x); Low[x]=min (Low[x],low[v]), if (Dfn[x]<=low[v]) {do{temp=stk[top--];d [temp]++;} while (temp!=x); top++;}} else Low[x]=min (Low[x],dfn[v]);} return;} int main () {int I,t=0;int a,b;while (scanf ("%d", &a), a) {init (), int flag=1;printf ("Network #%d\n", ++t);d o{scanf ("%d ", &b); map[a][b]=map[b][a]=1;exist[a]=exist[b]=true;} while (scanf ("%d", &a), a), for (i=1;i<=1000;i++) if (Exist[i]&&!dfn[i]) Tarjan (i,0); for (i=1;i<=1000 ; i++) if (d[i]>=2) printf ("SPF node%d leaves%d subnets\n", I,d[i]), FLAG=0;IF (flag) puts ("No SPFNodes ");p UTS (" ");} return 0;}
"POJ1523" SPF Tarjan-two-connected Component Bare topic template problem