Link:
#include <stdio.h>int main(){ puts("转载请注明出处[辗转山河弋流歌 by 空灰冰魂]谢谢"); puts("网址:blog.csdn.net/vmurder/article/details/46437961");}
Exercises
Title. Calculate the fractional value first, and then see who else is connected to the source point.
Minimum cut map: The original image each point corresponds to a point, the original picture each edge corresponds to a point. Each edge corresponds to a point to each end point, and note that you want one-way edge.
This problem card accuracy:
So some of the details are grilled code bar QWQ
Eps:1e-5
Because it is a double network stream, the upper bound of the two points is not too large, the number of sides is good.
In addition, this code does not bzoj AC,
And the code in Bzoj can not necessarily be AC on the POJ,
What the heck.
Code:
#include <queue>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define N 12000#define M 70000#define EPS 1e-6#define INF 0x3f3f3f3fusing namespace STD;structeli{intV,n;Doublel;} E[M];inthead[n],cnt;inline voidAddintUintVDoubleL) {e[++cnt].v=v; E[cnt].l=l; E[cnt].n=head[u]; head[u]=cnt;}inline voidADD (intUintVDoubleL) {Add (u,v,l), add (V,u,0);}intS,t,dep[n]; Queue<int>QBOOLBFS () { while(!q.empty ()) Q.pop ();memset(DEP,0,sizeofDEP); Q.push (s), dep[s]=1;intI,u,v; while(!q.empty ()) {U=q.front (), Q.pop (); for(I=HEAD[U];I;I=E[I].N) {if(!dep[v=e[i].v]&&e[i].l>eps) {dep[v]=dep[u]+1;if(v==t)return 1; Q.push (v); } } }return 0;}DoubleDinic (intXDoubleFlow) {if(x==t)returnFlowintI,v;DoubleRemain=flow,k; for(I=HEAD[X];I&&REMAIN>EPS;I=E[I].N) {if(dep[v=e[i].v]==dep[x]+1&&e[i].l>eps) {k=dinic (V,min (REMAIN,E[I].L));if(k<eps) dep[v]=0; e[i].l-=k,e[i^1].l+=k; Remain-=k; } }returnFlow-remain;}intU[n],v[n],n,m;BOOLCheckDoubleMID) {intImemset(Head,0,sizeofHead); for(cnt=i=1; i<=m;i++) {Add (n+i,u[i],inf); ADD (N+i,v[i],inf); } for(i=1; i<=n;i++) Add (I,t,mid); for(i=1; i<=m;i++) Add (S,n+i,1);DoubleMaxflow=m; while(BFS ())) maxflow-=dinic (S,inf);returnMaxflow>eps;}intMain () {//Freopen ("Test.in", "R", stdin); intI while(scanf("%d%d", &n,&m)!=eof) {if(!m) {puts("1\n1");Continue; } s=0, t=n+m+1; for(i=1; i<=m;i++)scanf("%d%d", &u[i],&v[i]);DoubleL=0, R=m,mid; while(L +1e-5<r) {mid= (l+r)/2.0;if(Check (mid)) L=mid;ElseR=mid; } check (L), BFS ();intans=0; for(i=1; i<=n;i++)if(Dep[i]) ans++;printf("%d\n", ans); for(i=1; i<=n;i++)if(Dep[i])printf("%d\n", i); }return 0;}
"POJ3155" Hard Life score plan + min cut