Title: The number of points connected to a graph without n<=50
Idea: To delete some points, so that the diagram is not connected, the key is to examine the concept of "non-unicom". In fact, the non-unicom is the existence of two points no road connected. To consider enumerating two points, the problem is reduced to two points without a path. However, this is done with minimal cut, because the minimum cut model is to delete the edge, so each point is split into two points plus one side, the enumeration of the two points is the source and meeting point, run the smallest cut on the line.
I think the smallest cut after the have been thinking how to award Unicom ... It's too young.
BTW, it is not right to enumerate only one point in most of the puzzle. For example, you fixed the source point, the default source point can not be deleted, but just delete this point optimal?
Give the hack data:
3 2 (0,1) (0,2)
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cassert>5#include <queue>6 7 using namespacestd;8 9 Const intn= -+3, m= the+3;Ten Const intinf=0x3f3f3f3f; One A structedge{ - intNXT,TO,FL; - }ed[m]; the - inthead[n],cur; - ints,t; -queue<int>Q; + intCap[n],fr[n]; - + voidAdd_edge (intLintRintf) A { ated[cur]=(Edge) {head[l],r,f}; -head[l]=cur++; -Ed[cur]= (Edge) {head[r],l,0}; -head[r]=cur++; - } - in intn,m; - int Get; to BOOLek () + { -memset (Cap,0,sizeof(CAP)); thecap[s]=INF; * while(!q.empty ()) Q.pop (); $ Q.push (s);Panax Notoginseng while(!q.empty ()) - { the intu=Q.front (); Q.pop (); + for(inti=head[u];i!=-1; i=ed[i].nxt) A if(!cap[ed[i].to]&&ed[i].fl) thecap[ed[i].to]=min (cap[u],ed[i].fl), +fr[ed[i].to]=I, - Q.push (ed[i].to); $ if(Cap[t]) Break; $ } - if(!cap[t])return 0; - Get+=Cap[t]; the for(intu=t;u!=s;u=ed[fr[u]^1].to) -ed[fr[u]].fl-=Cap[t],Wuyied[fr[u]^1].fl+=Cap[t]; the return 1; - } Wu - About $ intL[m],r[m]; - intMain () - { - while(SCANF ("%d%d", &n,&m)! =EOF) A { + for(intI=1; i<=m;i++) thescanf"(%d,%d)",&l[i],&r[i]); - intans=N; $ for(s=0; s<n;s++) the for(t=s+1; t<n;t++) the { theMemset (Head,0xFF,sizeof(head)); theCur=0; - Get=0; in for(intI=1; i<=m;i++) theAdd_edge (l[i],r[i]+n,n), theAdd_edge (r[i],l[i]+n,n); About for(intI=0; i<n;i++) the if(i==t| | i==s) theAdd_edge (i+n,i,n); the Else +Add_edge (I+n,i,1); - while(EK ()); theAns=min (ans,Get);Bayi } thecout<<ans<<Endl; the } - return 0; -}[]
[min Cut] Cable TV Network UVA-1660 POJ-1966