Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define fi first
- #define se second
- using namespace std;
- using ftype = long double;
- const ftype eps = 1e-9;
- int n, k;
- vector<vector<int>> gr;
- vector<int> mt;
- vector<bool> used;
- bool try_kuhn(int v) {
- if (used[v]) return false;
- used[v] = true;
- for (int to : gr[v]) {
- if (mt[to] == -1 or try_kuhn(mt[to])) {
- mt[to] = v;
- return true;
- }
- }
- return false;
- }
- ftype getDistance(ftype a, ftype b, ftype c, ftype d) {
- return sqrtl((a - c) * (a - c) + (b - d) * (b - d));
- }
- int main() {
- int s, v;
- while (cin >> n >> k >> s >> v and n) {
- vector<pair<ftype, ftype>> coord, coordHoles;
- gr.assign(n + k, vector<int>());
- used.assign(n + k, false);
- for (int i = 0; i < n; ++i) {
- ftype a, b; cin >> a >> b;
- coord.push_back({a, b});
- }
- for (int i = 0; i < k; ++i) {
- ftype a, b; cin >> a >> b;
- coordHoles.push_back({a, b});
- }
- for (int i = 0; i < n; ++i) {
- for (int j = 0; j < k; ++j) {
- ftype distance = getDistance(coord[i].fi, coord[i].se, coordHoles[j].fi, coordHoles[j].se);
- if (distance <= (ftype)s * v+eps) {
- gr[i].push_back(n + j);
- gr[n + j].push_back(i);
- }
- }
- }
- mt.assign(n + k, -1);
- vector<bool> used1(n, false);
- for (int v = 0; v < n; ++v) {
- for (int to : gr[v]) {
- if (mt[to] == -1) {
- mt[to] = v;
- used1[v] = true;
- break;
- }
- }
- }
- int cnt = 0;
- for (int v = 0; v < n + k; ++v) {
- if (used1[v]) continue;
- used.assign(n + k, false);
- int r = try_kuhn(v);
- // cout << r << '\n';
- cnt += r;
- }
- // for (int i = 0; i < n + k; ++i)
- // if (mt[i] != -1)
- // cout << mt[i] << ' ' << i << '\n';
- // cout << cnt << '\n';
- cout << max(0, n-cnt) << '\n';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment