Connect the server through the IP address and port

2023-03-14  

Description

The gopher family, having averted the canine threat, must face a new predator. 

The are 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 is vulnerable to being eaten. A hole can save at 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 each 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 are in metres; all times are in seconds; all velocities are in metres per second.

output

Output consists of a single line for each case, giving the number of vulnerable gophers.

Sample input

2 2 5 10
1.0 1.0
2.0 2.0
100.0 100.0

20.0 20.0

Sample output

1

This question is relatively intended … It is said that there are N mice, M holes, the time S of the eagle reaches the ground, the mouse’s movement speed V, how many pickers will be eaten by the eagle. If this is established, the mouse and hole should be regarded as two sets. Then only the time from the local mouse to the cave is less than the time from the eagle to the ground.

#include <stdio.h> 
 #include <string.h> 
 #include <string> 
 #include <math.h> 
 #include <vector> 
 #include <queue> 
 #include <stack> 
 #include <map> 
 #include <iOSTREAM> 
 #include <algorithm> 
 using namespace std; 
 int n, m, ma [505] [505], vis [505], dx [505]; 
 struct point 
 {{ 
     double x, y; 
 } G [200], h [200]; 
 Double DIS (Point P1, Point P2) 
 {// The time of calculating the mouse to the hole 
     Return SQRT ((P2.X-P1.x)*(P2.x-P1.x)+(P2.y-P1.y)*(p2.y-p1.y)); 
 } 
 int Find (int i) 
 {{ 
 for (int j = n+1; j <= n+m; j ++) 
 {{ 
 if (ma [i] [j] && vis [j] == 0) 
 {{ 
 vis [j] = 1; 
 if (dx [j] ==-1 || Find (dx [j]))) 
 {{ 
 dx [j] = i; 
 Return 1; 
 } 
 } 
 } 
 Return 0; 
 } 
 int Main () 
 {{ 
 int T, I, J, S, V, X, Y, Sum; 
 While (Scanf ("%D%D%D%D", & N, & M, & S, & V)! = EOF) 
 {{ 
 if (t == 0) Break; 
 Memset (ma, 0, sizeof ma); 
 MEMSET (VIS, 0, SIZEOF VIS); 
 Memset (dx, -1, sizeof dx); 
 for (i = 1; i <= n; i ++) 
         scanf ("%lf%lf", & g [i] .x, & g [i] .y); 
         for (i = 1; i <= m; i ++) 
         scanf ("%lf%lf", & h [i] .x, & h [i] .y); 
         for (i = 1; i <= n; i ++) 
 {{ 
             for (j = 1; j <= m; j ++) 
 {{ 
                 double d = dis (g [i], h [j]); 
                 if (d/v <= (double) s) // is safer than the eagle 
                 ma [i] [n+j] = 1; 
             } 
         } 
 sum = 0; 
 for (i = 1; i <= n; i ++) 
 {{ 
 MEMSET (VIS, 0, SIZEOF VIS); 
 SUM+= Find (i); 
 } 
 Printf ("%d \ n", n-sum); 
 } 
 }

source

Related Posts

[RUST Tiring Notes] Rust basic grammar data type -02

Set up LAMP services (Apache, MySQL, PHP)

How to completely uninstall Anaconda? LORD

[A must -have for the interview] In 2021, you are just a notes with bytes. The content is too real.

Connect the server through the IP address and port

Random Posts

Competition Practice Issue 15: Electronic Society September 2021 Youth Software Programming (graphic) level test papers (level 3) …

Thinkcmf any file to write vulnerabilities —- Learning records

Create uboot environment variable BIN file

Master this posture, girlfriend no longer talks about

Solving the high version of OpenCV4.3 about basic data types CVPOINT, CVSCALAR error toky