wa了一次,因为输出成能跑掉的gopher了,问的是有危险的。
囧!
/* * Author: stormdpzh * POJ: 2536 Gopher II * Created Time: 2012/5/19 10:21:28 */ #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <cmath> #include <vector> #include <queue> #include <stack> #include <map> #include <set> #include <algorithm> #include <functional> #define sz(v) ((int)(v).size()) #define rep(i, n) for(int i = 0; i < n; i++) #define repf(i, a, b) for(int i = a; i <= b; i++) #define repd(i, a, b) for(int i = a; i >= b; i--) #define out(n) printf("%d\n", n) #define wh(n) while(scanf("%d", &n) != EOF) #define whz(n) while(scanf("%d", &n) != EOF && n != 0) #define lint long long using namespace std; const int MaxN = 105; int n, m, s, v; int x[MaxN], y[MaxN]; double placex[MaxN], placey[MaxN], holex[MaxN], holey[MaxN]; bool visited[MaxN]; bool mp[MaxN][MaxN]; double getDis(int i, int j) { return sqrt((placex[i] - holex[j]) * (placex[i] - holex[j]) + (placey[i] - holey[j]) * (placey[i] - holey[j])); } void init() { memset(mp, false, sizeof(mp)); rep(i, n) scanf("%lf%lf", &placex[i + 1], &placey[i + 1]); rep(i, m) scanf("%lf%lf", &holex[i + 1], &holey[i + 1]); repf(i, 1, n) repf(j, 1, m) { if(getDis(i, j) / (double)v <= (double)s) mp[i][j] = true; } } bool search(int v) { repf(i, 1, m) { if(!visited[i] && mp[v][i]) { visited[i] = true; if(y[i] == -1 || search(y[i])) { y[i] = v; x[v] = i; return true; } } } return false; } int gao() { int res = 0; memset(x, -1, sizeof(x)); memset(y, -1, sizeof(y)); repf(i, 1, n) { if(x[i] == -1) { memset(visited, false, sizeof(visited)); if(search(i)) res++; } } return res; } int main() { while(scanf("%d%d%d%d", &n, &m, &s, &v) != EOF) { init(); out(n - gao()); } return 0; }