版权声明:本文为博主原创文章,未经博主允许不得转载。(除非给钱。。。/贪婪) https://blog.csdn.net/SSL_zeng_yu/article/details/78904071
地鼠的困境 Time Limit:1000MS Memory Limit:65536K Description 地鼠家族面临着一个新的威胁——猎食者。 Input 本题有多组数据。第1行为测试数据组数T(T<=50)。 Output 对于每组数据输出一行,为易受攻击的地鼠的数量。 Sample Input
1
2 2 5 10
1.0 1.0
2.0 2.0
100.0 100.0
20.0 20.0
扫描二维码关注公众号,回复:
4419134 查看本文章
Sample Output
1 Source elba [Submit] [Go Back] [Status] [Discus 分析: 首先预处理出每个地鼠能够跑到点,然后连起来,之后想一个正常的二分图一样的 去写就好了。
var link:array[0..101] of longint; cover:array[0..101] of boolean; map:array[0..101,0..101] of boolean; a,b,j,i,k,l,n,m,v,t:longint; function find(x,y:longint):boolean; var q,i:longint; begin find:=true; for i:=1 to y do if map[x,i] and not(cover[i]) then begin q:=link[i]; link[i]:=x; cover[i]:=true; if (q=0) or (find(q,y)) then exit; link[i]:=q; end; find:=false; end; procedure main(x:longint); var i:longint; begin for i:=1 to x do begin fillchar(cover,sizeof(cover),false); find(i,x); end; end; procedure work(a,b,c:longint); var i,j,k,max,ans:longint; r,s,x0,y0,q,p:real; x,y:array[0..101] of real; begin for i:=1 to a do readln(x[i],y[i]); for i:=1 to b do begin readln(q,p); for j:=1 to a do begin x0:=x[j]-q; y0:=y[j]-p; r:=sqrt(sqr(x0)+sqr(y0)); if r<=c then map[j,i]:=true; end; end; main(a); ans:=0; for i:=1 to a do if link[i]>0 then inc(ans); writeln(a-ans); end; begin readln(n); for i:=1 to n do begin readln(a,b,v,t); fillchar(map,sizeof(map),false); fillchar(link,sizeof(link),false); work(a,b,v*t); end; end. |