It is said that this is a word final question, Orz ...
Original title Link: Https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem &problem=3136
Test instructions
Give you a link map, let you choose some points, so that any point of the graph disappears, the rest of the points can reach a point of your choice. Ask you at least which points to choose, and how many scenarios the output is in the best case.
Exercises
At the glance of the past, the practice is very simple, delete all the cut points, the number of inspection unicom block is good. But this problem is full of holes. It's not a finals question.
First, if the graph has only one unicom block, then the answer should be any of the two points, because if one of the points hangs, you can go another point.
If a unicom block has more than one cut point, then this unicom block is not required, this is because two cut points can not be hung at the same time.
Code:
#include <iostream>#include<cstring>#include<algorithm>#include<vector>#include<Set>#defineMax_v 50004using namespacestd;intv=0; Vector<int>G[max_v];intN;intDfn[max_v],low[max_v],ind=0;BOOLVis[max_v];BOOLIscut[max_v];inttot=0;Long Longways=1;Long Longtmp=0;Long LongCnt=0;BOOLUsed[max_v];Set<int>se;voidinit () {se.clear (); V=ind=cnt=tmp=0; Ways=1; memset (Used,0,sizeof(used)); memset (DFN,0,sizeof(DFN)); memset (Low,0,sizeof(low)); memset (Vis,0,sizeof(VIS)); memset (Iscut,0,sizeof(Iscut)); for(intI=0; i<=n+2; i++) G[i].clear ();}voidTarjan (intUintp) {Dfn[u]= Low[u] = + +IND; Vis[u]=1; intChild =0; for(inti =0; I < g[u].size (); i++) { intv =G[u][i]; if(v = = p)Continue; if(!Vis[v]) { Child++; Tarjan (V, u); Low[u]=min (Low[v], low[u]); if(p = =0&& Child >1) Iscut[u] =1; if(P&&low[v] >=Dfn[u]) Iscut[u]=1; Tot+=Iscut[u]; } ElseLow[u]=min (Dfn[v], low[u]); }}voidDfsintu) {if(Used[u] | | iscut[u])return; TMP++; Used[u]=1; for(inti =0; I < g[u].size (); i++){ intv=G[u][i]; if(Iscut[v]) {Se.insert (v); Continue; } dfs (v); }}intMain () {intCAS =0; Cin.sync_with_stdio (false); while(Cin >>N) {tot=0; if(N = =0) Break; Init (); for(inti =0; i < N; i++) { intu, v; CIN>> u >>v; V=Max (V, max (U, v)); G[u].push_back (v); G[v].push_back (U); } Tarjan (1,0); cout<<" Case"<< ++cas <<": "; if(Tot = =0) {cout<<2<<" "<< (Long Long) v * (V-1) /2<<Endl; Continue; } for(intU =1; U <= V; u++) { if(Iscut[u])Continue; TMP=0; if(!Used[u]) {se.clear (); DFS (U); if(se.size () = =1&&tmp) {Ways*=tmp; CNT++; } }} cout<< CNT <<" "<< ways <<Endl; } return 0;}
Uvalive 5135 Mining Your OWN Business Dual connectivity components