The main problem: There are n mice, m holes, a hole can only hide a mouse.
There was a flock of eagles, and the mice had to hide in the cave before they could be taken away.
Now give the coordinates of each mouse, the coordinates of each hole, the speed of the mouse, and the time the eagle catches the mouse, asking the eagle to catch a few mice at least.
How to solve the problem: find the distance between each mouse and each hole, and then, in addition to the speed of the mouse, see whether the eagle catches the mouse in time to run into the hole.
Then divide the mouse and the hole into two point sets, the maximum match of the binary graph, and then the N-Max match is the number of mice the eagle can catch at least.
#include <cstdio>#include <cstring>#include <cmath>using namespace STD;Const intN = the;Const DoubleESP =1e-7;DoubleDis[n][n], pos[n][2], hole[n][2];intG[n][n], Vis[n], link[n], N, M, S, v;DoubleDistanceDoubleX1,DoubleX2,DoubleY1,Doubley2) {return sqrt((X1-X2) * (X1-X2) + (y1-y2) * (Y1-y2));voidInit () { for(inti =0; I < n; i++)scanf("%LF%LF", &pos[i][0], &pos[i][1]); for(inti =0; I < m; i++)scanf("%LF%LF", &hole[i][0], &hole[i][1]);memset(g,0,sizeof(g)); for(inti =0; I < n; i++) for(intj =0; J < M; J + +) {Dis[i][j] = distance (pos[i][0], hole[j][0], pos[i][1], hole[j][1]);if(Dis[i][j]/v-s <= ESP) G[I][J] =1; }memset(Link,-1,sizeof(link));}BOOLDfsintu) { for(inti =0; I < m; i++) {if(Vis[i] | |!g[u][i])Continue; Vis[i] =1;if(Link[i] = =-1|| DFS (Link[i])) {Link[i] = u;return true; } }return false;}voidHungary () {intAns =0; for(inti =0; I < n; i++) {memset(Vis,0,sizeof(VIS));if(Dfs (i)) ans++; }printf("%d\n", N-ans);}intMain () { while(scanf("%d%d%d%d", &n, &m, &s, &v)! = EOF) {init (); Hungary (); }return 0;}
POJ-2536 Gopher II binary graph maximum matching