Gopher II
Total Time Limit:2000msmemory limit:65536kb
Description
The Gopher family, having averted of the canine threat, must face a new predator.
The is N gophers and M gopher holes, each at distinct (x, y) coordinates. A hawk arrives and if a gopher does not reach a hole in s seconds it's vulnerable to being eaten. A hole can save at the most one gopher. All the Gophers run at the same velocity v. The Gopher family needs an escape strategy that minimizes the number of vulnerable Gophers.
Input
The input contains several cases. The first line of all case contains four positive integers less than 100:n, M, S, and V. The next n lines give the coordinates of the Gophers; The following m lines give the coordinates of the gopher holes. All distances is in metres; All times is in seconds; All velocities is in metres per second.
Output
Output consists of a, giving the number of vulnerable Gophers.
Sample Input
2 2 5 101.0 1.02.0 2.0100.0 100.020.0 20.0
Sample Output
-
1
The problem of a two-part graph
Know not to learn the new algorithm before the exam, but see that they will not, or can not help learning a night
The Hungarian algorithm for the maximum matching of binary graphs.
Constantly seek to broaden the road, each time you can make the answer +1
As long as the sqrt (SQR (mouse[i].x-hole[j].x) +SQR (MOUSE[I].Y-HOLE[J].Y)) <=v*s
The elements of I and the set of holes in the collection of the mouse are connected to one side of the element of J.
CODE:
var nM, SV: Longint; IJK: Longint; Pole:Array[1..500]OfRecord XY:Real;End; Mouse:Array[1..500]OfRecord XY:Real;End; Edge:Array[1..200,1..200]OfBoolean; Match:Array[1..500]of Longint; Used:Array[1..500]OfBoolean; Ans: Longint;functionDfs(x: Longint):Boolean;var iJK: Longint;BeginFor I:=1to MDoIf(Edge[x, I])and(Used[I])ThenBegin used[I]:=False;If match[I]=0ThenBegin match[I]:=x;Exit(True);EndElseBeginIfDfs(Match[I])ThenBegin match[I]:=x;Exit(True);End;End;End;Exit(False);End;BeginWhileNot EOFDoBeginFillchar(Mouse,sizeof(Mouse),0);Fillchar(Pole,sizeof(Pole),0);Readln(nM, SV);For I:=1to nDoReadln(Mouse[I].x, mouse[I].y);For I:=1to MDoReadln(Pole[I].x, pole[I].y);Fillchar(Edge,sizeof(Edge),False);For I:=1to nDoFor J:=1to MDoIfsqrt(Sqr(Mouse[I].x-pole[j].x)+Sqr(Mouse[I].y-pole[j].y)) <=s*vThen Edge[IJ]:=True;Fillchar(Match,sizeof(Match),0); Ans:=0;For I:=1to ndo begin fillchar (Used,sizeof (Usedtrue); if dfs (Ithen inc (Ansend; writeln (N-ans ); end; End
Noip Eve: Noi.openjudge,gopher II