HDU 5765 Bonds Subtle pressure violence

Source: Internet
Author: User

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&LT;&LT;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

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.