Two-point answer ... Then the maximum flow verification is possible ...
No, it's good water, Qaq.
1 /**************************************************************2 problem:39933 User:rausen4 language:c++5 result:accepted6 time:40 Ms7 memory:1156 KB8 ****************************************************************/9 Ten#include <cstdio> One#include <cstring> A#include <algorithm> - - using namespacestd; thetypedefDoubleLF; - Const intN = the; - ConstLF inf =1e10; - ConstLF EPS = 1e-7; + Const intM = n * N <<1; - +Inlineintread (); A at structEdge { - intnext, to; - LF F; -Edgeint_n =0,int_t =0, lf _f =0.0): Next (_n), to (_t), F (_f) {} - } E[m]; - in intN, M, S, T; - intB[n]; to intFirst[n], tot =1; + intQ[n], d[n]; - theInlinevoidAdd_edges (intXinty, lf z) { *E[++tot] = Edge (first[x], y, z), first[x] =tot; $E[++tot] = Edge (First[y], X,0), first[y] =tot;Panax Notoginseng } - the #defineY e[x].to + #defineP Q[l] A BOOLBFs () { the Static intL, R, X; +memset (D,-1,sizeof(d)); -d[q[1] = S] =1; $ for(L = r =1; L! = r +1; ++l) $ for(x = first[p]; x; x =e[x].next) - if(!~d[y] && e[x].f >EPS) { -D[q[++r] = y] = d[p] +1; the if(y = = T)return 1; - }Wuyi return 0; the } - #undefP Wu -LF Dfs (intp, LF Lim) { About if(p = = T | |!lim)returnLim; $ intx; -LF tmp, rest =Lim; - for(x = first[p]; x && rest > eps; x =e[x].next) - if(D[y] = = D[p] +1&& (tmp = min (e[x].f, rest) >EPS)) { ARest-= (TMP =dfs (y, tmp)); +E[X].F-= tmp, E[x ^1].F + =tmp; the if(!rest)returnLim; - } $ if(Rest > EPS) d[p] =-1; the returnLim-rest; the } the theInlineBOOLcheck (LF t) { - Static intx; in for(x =2; x <= tot; X + =2) theE[x].f + = e[x ^1].F, E[x ^1].F =0; the for(x = first[s]; x; x =e[x].next) AboutE[X].F = b[y-n] *T; the while(BFS ()) DFS (S, INF); the for(x = first[t]; x; x =e[x].next) the if(e[x ^1].F > EPS)return 0; + return 1; - } the #undefYBayi the intMain () { the intI, J; - LF L, R, Mid; -n = Read (), M =read (); theS = n + M +1, T = S +1; the for(i =1; I <= N; ++i) the add_edges (i, T, read ()); the for(i =1; I <= m; ++i) -B[i] = Read (), Add_edges (S, n + i,0); the for(i =1; I <= m; ++i) the for(j =1; J <= N; ++j) the if(read () = =1) add_edges (n +I, J, INF);94L =0, r =5e6; the while(R-l >EPS) { theMid = (L + r)/2.0; the if(Check (mid)) R =mid;98 ElseL =mid; About } -printf"%.6lf\n", (L + R)/2.0);101 return 0;102 }103 104InlineintRead () { the Static intx;106 Static Charch;107x =0, ch =GetChar ();108 while(Ch <'0'||'9'<ch)109CH =GetChar (); the while('0'<= CH && Ch <='9') {111x = x *Ten+ CH-'0'; theCH =GetChar ();113 } the returnx; the } the View Code
BZOJ3993 [SDOI2015] Star Wars