Click to open link
Test instructions: Give a relationship between the graph and the edge, and find out the number of cut points
Train of thought: no-map cut point pure template, not to say, this write very good understanding point here
#include <vector> #include <stdio.h> #include <string.h> #include <stdlib.h> #include < Iostream> #include <algorithm>using namespace std;typedef long long ll;const int Inf=0x3f3f3f3f;const int maxn= 110;vector<int>g[maxn];int e[maxn],l[maxn],vis[maxn],cnt[maxn];int k,kk;void dfs (int x) {k++; E[x]=k; L[x]=k;vis[x]=1; for (unsigned int i=0;i<g[x].size (); i++) {int t=g[x][i]; if (!vis[t]) {DFS (T); L[x]=min (L[x],l[t]); if (l[t]>=e[x]&&x!=1) cnt[x]++; else if (x==1) kk++; }else l[x]=min (l[x],e[t]); }}int Main () {int n,a,b,c; while (scanf ("%d", &n)!=-1) {if (n==0) break; for (int i=0;i<maxn;i++) g[i].clear (); memset (vis,0,sizeof (VIS)); memset (cnt,0,sizeof (CNT)); while (scanf ("%d", &a)!=-1) {if (a==0) break; while (GetChar ()! = ' \ n ') {scanf ("%d", &b); G[a].push_back (b); G[b].push_back (a); }} int ans=0; K=0;kk=0;dfs (1); if (kk>=2) ans++; for (int i=1;i<=n;i++) {if (cnt[i]>=1) ans++; } printf ("%d\n", ans); } return 0;}
POJ 1144 non-direction graph cutting Point template problem