Test instructions: Give a 20-point undirected graph to find out how many minimum cut sets are included in each edge
Analysis: The minimum cut set is the set of edges, it is clear that the minimum cut set happens to be divided into two parts (this if you do not understand can be used to disprove the law)
And then there's the official puzzle: http://bestcoder.hdu.edu.cn/blog/2016-school Training 4th 1003
In fact, the general idea is to enumerate a possible cut set each time, that is, the pressure enumeration, which has an illegal, can be pre-processing to mark all the legitimate state
All that's left is the code, and it's important to look at the code details.
#include <cstdio>#include<cstdlib>#include<cstring>#include<cmath>#include<iostream>#include<algorithm>#include<map>#include<queue>#include<vector>using namespaceStd;typedefLong LongLL;Const intN = (1<< -)+5;intg[n],sum[n],t,kase,n,m,u[205],v[205],tot;BOOLCan[n];queue<int>Q;inlineintLowbit (intx) {returnx& (-x);}intMain () {scanf ("%d",&u); while(t--) {scanf ("%d%d", &n,&m), tot=1<<N; Memset (g,0,sizeof(g)); Memset (CAN,false,sizeof(Can)); memset (SUM,0,sizeof(sum)); for(intI=0; i<m;++i) {scanf ("%d%d",&u[i],&V[i]); g[1<<u[i]]|=1<<V[i]; g[1<<v[i]]|=1<<U[i]; } for(intI=1; i<tot;++i) g[i]|=g[i-lowbit (i)]|g[lowbit (i)]; for(intI=0; i<n;++i) Q.push (1<<i), can[1<<i]=true; while(!Q.empty ()) { intu=Q.front (); Q.pop (); intgo=g[u]^ (g[u]&T); while(GO) {intTo=lowbit (GO) |u; if(!can[to]) Q.push (to), can[to]=true; Go-=lowbit (GO); } } intAll=0; for(intI=1; i<tot;++i) { intJ= (tot-1)^i; if(i<j&&can[i]&&Can[j]) { ++sum[i];++sum[j];++All ; } } for(intj=0; j<n;++j) { for(inti=tot-1;i>0;--i)if(! (i& (1<<J)) sum[i]+=sum[i^ (1<<j)]; } printf ("Case #%d:",++Kase); for(intI=0; i<m;++i) printf ("%d", all-sum[(1<<u[i]) | (1<<V[i]); printf ("\ n"); } return 0;}
View Code
HDU 5765 Bonds Subtle pressure violence