http://acm.hdu.edu.cn/showproblem.php?pid=3394
Title Description:
There is a park with N attractions, the park's administrators are ready to build M roads, and to arrange a number of circuit-forming tour routes. If a road is shared by multiple roads, the road is in conflict, and if a road is not in any circuit, then the road is not in conflict.
Ask how many conflicting paths and no conflict paths.
Analysis:
Just learn some double and side double, see the problem is not clear which is which ~
This topic is for double. There is a conflict on one side, indicating that there are more than two rings in the two connected components of the point, there is no conflict indicating that this edge is a bridge
How do you determine the number of rings in a two-connected component? According to the relationship between the number of points and the edge
1. When points = number of sides, form a ring
2. When points > sides (a line segment, indicating that this edge is a bridge)
3. When the number of points < sides, then 1 or more rings are included
//296ms 3624K 2190 B#include <cstring>#include <cstdio>#include <iostream>#define REP (i,n) for (int i=0;i< (n); ++i)#define REP1 (I,A,B) for (int i= (a);i< (b); ++i)#define MAX (A, B) (A<B?B:A)Const intmaxn=10010;Const intmaxm=100010;using namespace STD;intLOW[MAXN],DFN[MAXN],STACK[MAXN],BCC[MAXN];intDfs_clock,top;BOOLOK[MAXN];intTMP[MAXN],CC;intN,m;intAns1,ans2;structedge{intTo,next;} edge[maxm<<1];intHead[maxn],tot;voidAddedge (intUintV) {edge[tot].to=v;edge[tot].next=head[u];head[u]=tot++;}voidInit () {tot=0;memset(Head,0xFF,sizeof(head));}voidCount () {intsum=0, U,v; for(intI=0; i<cc;++i) {u=tmp[i]; for(intj=head[u];j!=-1; j=edge[j].next) {v=edge[j].to;if(Ok[v]) sum++; }} sum/=2;if(SUM>CC) Ans2+=sum;}voidDfsintUintPre) {intV Low[u]=dfn[u]=++dfs_clock; Stack[top++]=u; for(inti=head[u];i!=-1; i=edge[i].next) {v=edge[i].to;if(V==pre)Continue;if(!dfn[v]) {DFS (V,U);if(Low[u]>low[v]) low[u]=low[v];if(Low[v]>dfn[u]) ans1++;if(Low[v]>=dfn[u]) {cc=0;memset(OK,false,sizeof(OK));intVn for(;;) {Vn=stack[--top]; TMP[CC++]=VN; ok[vn]=true;if(VN==V) Break; } tmp[cc++]=u; ok[u]=true; Count (); } }Else if(Low[u]>dfn[v]) low[u]=dfn[v]; }}voidSolve () {memset(DFN,0,sizeof(DFN)); dfs_clock=top=0; Ans1=ans2=0; for(intI=0; i<n;++i) {if(!dfn[i]) DFS (i,-1); }printf("%d%d\n", ans1,ans2);}intMain () {#ifndef Online_judgeFreopen ("In.cpp","R", stdin);#endif //Online_judge intU,v; while(scanf("%d%d", &n,&m) = =2){if(n==0&&m==0) Break; Init (); while(m--) {scanf("%d%d", &u,&v); Addedge (U,V); Addedge (V,u); } solve (); }return 0;}
HDU3394. railway--Point Double connected component