-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy path10080 - Gopher II.cpp
55 lines (42 loc) · 1.09 KB
/
10080 - Gopher II.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <stdio.h>
#include <vector>
#include <memory.h>
#include <math.h>
using namespace std;
int const N = 101;
int n, m, s, v, match[N];
bool vis[N];
vector<pair<double, double> > a, b;
double dist(pair<double, double> p1, pair<double, double> p2) {
return sqrt(pow(p1.first - p2.first, 2.0) + pow(p1.second - p2.second, 2.0));
}
bool findMatch(int i) {
vis[i] = true;
for(int j = 0; j < m; ++j)
if(1.0 * dist(a[i], b[j]) / v <= s && (match[j] == -1 || (!vis[match[j]] && findMatch(match[j])))) {
match[j] = i;
return true;
}
return false;
}
int main() {
while(scanf("%d%d%d%d", &n, &m, &s, &v) != EOF) {
a.clear();
b.clear();
a.resize(n);
b.resize(m);
for(int i = 0; i < n; ++i)
scanf("%lf%lf", &a[i].first, &a[i].second);
for(int i = 0; i < m; ++i)
scanf("%lf%lf", &b[i].first, &b[i].second);
int res = 0;
memset(match, -1, sizeof match);
for(int i = 0; i < n; ++i) {
memset(vis, false, sizeof vis);
if(findMatch(i))
++res;
}
printf("%d\n", n - res);
}
return 0;
}