bzoj1822

时间:2023-03-10 04:56:05
bzoj1822

显然是二分+最大流判定
但比较烦的是判断线段和圆及其内部是否有公共点
我的判断方法是错的,但是数据弱
目前只知道推公式分类讨论,如果有简单的方法求教

 const inf=;
type node=record
flow,po,next:longint;
end;
point=record
x,y:longint;
end; var e:array[..] of node;
a,b,c:array[..] of point;
can:array[..,..] of boolean;
g,cur,v,w,pre,p,numh,h:array[..] of longint;
q,l,r,t,ans,mid,i,j,n,m,k,len:longint;
ff,ch:boolean; function dis(a,b:point):double;
begin
exit(sqrt(sqr(a.x-b.x)+sqr(a.y-b.y)));
end; function cross(a,b,c:point):double;
begin
cross:=abs((a.x-b.x)*(a.y-c.y)-(a.x-c.x)*(a.y-b.y));
cross:=cross/dis(a,b);
end; procedure add(x,y,f:longint);
begin
inc(len);
e[len].po:=y;
e[len].flow:=f;
e[len].next:=p[x];
p[x]:=len;
end; function sap:longint;
var u,i,j,tmp,q:longint;
begin
fillchar(h,sizeof(h),);
fillchar(numh,sizeof(numh),);
for i:= to t do
cur[i]:=p[i];
u:=;
sap:=;
numh[]:=t+;
while h[]<t+ do
begin
i:=cur[u];
while i<>- do
begin
j:=e[i].po;
if (e[i].flow>) and (h[u]=h[j]+) then
begin
pre[j]:=u;
cur[u]:=i;
u:=j;
if u=t then
begin
inc(sap);
if sap=m then exit;
while u<> do
begin
u:=pre[u];
j:=cur[u];
dec(e[j].flow);
inc(e[j xor ].flow);
end;
end;
break;
end;
i:=e[i].next;
end;
if i=- then
begin
dec(numh[h[u]]);
if numh[h[u]]= then exit;
tmp:=t;
q:=-;
i:=p[u];
while i<>- do
begin
j:=e[i].po;
if e[i].flow> then
if h[j]<tmp then
begin
q:=i;
tmp:=h[j];
end;
i:=e[i].next;
end;
h[u]:=tmp+;
inc(numh[h[u]]);
cur[u]:=q;
if u<> then u:=pre[u];
end;
end;
end; function check(s:longint):boolean;
var q,i,j:longint;
begin
fillchar(p,sizeof(p),);
len:=-;
q:=;
for i:= to n do
begin
add(,i,s div w[i]+);
add(i,,);
if s div w[i]*w[i]>q then q:=s div w[i]*w[i];
end;
for i:= to m do
begin
add(i+n,t,);
add(t,i+n,);
for j:= to n do
if can[i,j] then
begin
add(j,i+n,);
add(i+n,j,);
end;
end;
if sap=m then
begin
ans:=q;
exit(true);
end
else exit(false);
end; begin
readln(n,m,k);
for i:= to n do
begin
readln(a[i].x,a[i].y,v[i],w[i]);
if w[i]>r then r:=w[i];
end;
for i:= to m do
readln(b[i].x,b[i].y);
for i:= to k do
readln(c[i].x,c[i].y,g[i]);
for i:= to m do
begin
ch:=false;
for j:= to n do
if dis(b[i],a[j])<=v[j] then
begin
ff:=true;
for q:= to k do
if cross(b[i],a[j],c[q])<g[q] then
begin
ff:=false;
break;
end;
if ff then
begin
can[i,j]:=true;
ch:=true;
end;
end; if not ch then
begin
writeln(-);
halt;
end;
end;
t:=n+m+;
l:=;
r:=r*m;
while l<=r do
begin
mid:=(l+r) shr ;
if check(mid) then r:=ans- else l:=mid+;
end;
writeln(ans);
end.