标签:start http memset scan ova mem log ext bit
二分完用流判定...计算几何....
1 #include<bits/stdc++.h> 2 #define rep(i,l,r) for(int i=l;i<=r;++i) 3 using namespace std; 4 typedef double d; 5 const int N=102333,inf=1e8; 6 int head[N],tot=1,Dis[N],n,m,K,l,r,mid,ans,T; 7 struct Edge{ 8 int to,next,w; 9 }e[N]; 10 struct node{ 11 int x,y,t,r; 12 }a[N],b[N],c[N]; 13 inline node operator-(node a,node b){ 14 node t;t.x=a.x-b.x;t.y=a.y-b.y;return t; 15 } 16 inline d operator*(node a,node b){ 17 return a.x*b.y-a.y*b.x; 18 } 19 inline d dot(node a,node b){ 20 return a.x*b.x+a.y*b.y; 21 } 22 inline d dis(node a,node b){ 23 return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); 24 } 25 inline d dis(node a,node b,node p){ 26 if(dot(a-p,b-p)>0) 27 return min(dis(a,p),dis(b,p)); 28 return abs((p-a)*(b-a)/dis(a,b)); 29 } 30 bool pd(int x,int y){ 31 if(dis(a[x],b[y])>a[x].r)return 0; 32 rep(i,1,K)if(dis(a[x],b[y],c[i])<c[i].r)return 0; 33 return 1; 34 } 35 inline bool bfs(){ 36 for(int i=0;i<=T;i++) Dis[i]=-1; queue<int>q; q.push(0); Dis[0]=0; 37 while(!q.empty()) { 38 int x=q.front(); q.pop(); 39 for(int k=head[x];k;k=e[k].next) 40 if(Dis[e[k].to]<0 && e[k].w>0) { 41 Dis[e[k].to]=Dis[x]+1; q.push(e[k].to); 42 } 43 } 44 if(Dis[T]>0) return 1;else return 0; 45 } 46 int find(int x,int low){ 47 if(x==T) return low; 48 int delta=low,now; 49 for(int k=head[x];k;k=e[k].next) 50 if(e[k].w>0 && Dis[e[k].to]==Dis[x]+1){ 51 now=find(e[k].to,min(e[k].w,delta)); 52 e[k].w-=now; e[k^1].w+=now; delta-=now; 53 if(!delta) return low; 54 } 55 Dis[x]=-1; 56 return low-delta; 57 } 58 inline void ins(int u,int v,int w) { 59 e[++tot].to=v; e[tot].next=head[u]; head[u]=tot; e[tot].w=w; 60 } 61 inline void insert(int u,int v,int w) { 62 ins(u,v,w); ins(v,u,0); 63 } 64 inline bool run(int x){ 65 memset(head,0,sizeof head); tot=1; 66 rep(i,1,n) insert(0,i,x/a[i].t+1); 67 rep(i,1,n) rep(j,1,m) if(pd(i,j))insert(i,j+n,1); 68 rep(i,1,m) insert(i+n,T,1); 69 int sum=0; 70 while(bfs())sum+=find(0,inf); 71 return sum==m; 72 } 73 int main(){ 74 scanf("%d%d%d",&n,&m,&K); 75 rep(i,1,n) scanf("%d%d%d%d",&a[i].x,&a[i].y,&a[i].r,&a[i].t); 76 rep(i,1,m) scanf("%d%d",&b[i].x,&b[i].y); 77 rep(i,1,K) scanf("%d%d%d",&c[i].x,&c[i].y,&c[i].r); 78 ans=-1; r=20000*200; T=1+n+m; 79 while(l<=r){ 80 int mid=l+r>>1; 81 if(run(mid)) ans=mid,r=mid-1;else l=mid+1; 82 } 83 printf("%d\n",ans); 84 }
bzoj1822: [JSOI2010]Frozen Nova 冷冻波
标签:start http memset scan ova mem log ext bit
原文地址:http://www.cnblogs.com/Bloodline/p/6223532.html