Bzoj 3993: [SDOI2015] Second division of interstellar Warfare & network streaming __

Source: Internet
Author: User

In order to learn ISAP have done this problem. Feel ISAP and no more than dinic difficult to hit how much ...

Second, the source point to the laser edge, the weight of the total damage, laser to the robot can reach infinity, the robot to the meeting point, the weight of the armor value. Then meeting Point's Bender satisfies the answer.

But the strange thing is to set the upper bound of the second point to 5e6, and change it to sum (all the armor values of the robots). Then add a sentence of if (l>sum) while (1); After that, it's over. The answer will not exceed sum ah ... I hope the old driver can take me with me.

The AC code is as follows:

#include <iostream> #include <cstdio> #include <cstring> #define N #define M 5505 #define INF 10000000

using namespace Std;
int n,m,tot=1,gol,fst[n],cur[n],pnt[m],nxt[m],d[n],num[n],h[n],fa[n];
Double sum,a[n],b[n],len[m]; void Add (int x,int y,double z) {pnt[++tot]=y; len[tot]=z; nxt[tot]=fst[x]; fst[x]=tot;} void BFs () {memset (num,0,sizeof
	(num)); Memset (d,0x3f,sizeof (d));
	d[gol]=0; int head=0,tail=1;
	H[1]=gol;
		while (head<tail) {int x=h[++head],p; num[d[x]]++;
			for (p=fst[x]; p. p=nxt[p]) if (len[p^1]) {int y=pnt[p];
			if (d[y]>inf) {d[y]=d[x]+1; h[++tail]=y;
	Double Up () {int i; double tmp=inf;
	for (I=gol i; i=pnt[fa[i]^1]) tmp=min (Tmp,len[fa[i]);
	for (I=gol i; i=pnt[fa[i]^1]) {len[fa[i]]-=tmp; len[fa[i]^1]+=tmp;
return TMP;
	bool OK (double t) {int p,i,x=0;
	for (i=2; i<=tot; i+=2) {len[i]+=len[i^1]; len[i^1]=0;
	for (p=fst[0); p. p=nxt[p]) len[p]=b[pnt[p]]*t;
	memcpy (cur,fst,sizeof (FST)); Double flow=0; BFS ();
		while (D[0]<=gol) {if (X==gol) {flow+=up (); x=0;}
		BOOL Flag=1;
			for (p=cur[x]; p. p=nxt[p]) if (len[p]) {int y=pnt[p];
				if (d[x]==d[y]+1) {cur[x]=fa[y]=p; x=y; flag=0;
			Break
			} if (flag) {int mn=gol; cur[x]=fst[x];
			for (p=fst[x]; p; p=nxt[p]) if (len[p)) Mn=min (Mn,d[pnt[p]); num[d[x]]--;
			if (!num[d[x]]) break; d[x]=mn+1;
			num[d[x]]++;
		if (x) x=pnt[fa[x]^1];
} return flow>=sum;
	int main () {scanf ("%d%d", &n,&m); gol=n+m+1; int i,j,x;
		For (I=1 i<=n; i++) {scanf ("%lf", &a[i]); sum+=a[i]; Add (I+m,gol,a[i]);
	Add (gol,i+m,0);
	For (I=1 i<=m; i++) {scanf ("%lf", &b[i]), add (0,i,b[i)), add (i,0,0);
			For (I=1 i<=m; i++) for (j=1; j<=n; J + +) {scanf ("%d", &x);
		if (x) {Add (I,j+m,inf); add (j+m,i,0);}
	Double L=0,r=5e6,mid;
		while (L+1e-4<r) {mid= (l+r)/2; if (OK (mid)) R=mid;
	else L=mid;
	printf ("%.6f\n", L);
return 0;
 }

by Lych

2016.4.9

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.