"POJ1523" SPF Tarjan-two-connected Component Bare topic template problem

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.