POJ 2536 Gopher II
来源:互联网 发布:塞风翻墙 软件下载 编辑:程序博客网 时间:2024/05/02 02:50
Gopher II
Time Limit: 2000MS Memory Limit: 65536KTotal Submissions: 6672 Accepted: 2730
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.
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 101.0 1.02.0 2.0100.0 100.020.0 20.0
Sample Output
1
n只地鼠,m个洞,老鹰的到达地面的时间s,地鼠的移动速度v,求多少只地鼠会被老鹰吃了
#include <cstdio>#include <string.h>#include <stdlib.h>#include <stdio.h>#include <algorithm>#include <math.h>using namespace std;int n,m,s,v;int map[501][501],xx[501],yy[501],b[501];double xs[501];double ys[501];int dfs(int r){ for(int i=1;i<=m+n;i++) { if(map[r][i] && !b[i]) { b[i]=1; if(yy[i]==-1 || dfs(yy[i])) { yy[i]=r; xx[r]=i; return 1; } } } return 0;}int pipei(){ memset(xx,-1,sizeof(xx)); memset(yy,-1,sizeof(yy)); int ans=0; for(int i=1;i<=n;i++) { if(xx[i]==-1) { memset(b,0,sizeof(b)); ans+=dfs(i); } } return ans;}int main(){ while(~scanf("%d%d%d%d",&n,&m,&s,&v)) { int i,j; memset(map,0,sizeof(map)); for(i=1;i<=n;i++) scanf("%lf%lf",&xs[i],&ys[i]); for(i=n+1;i<=n+m;i++) scanf("%lf%lf",&xs[i],&ys[i]); for(i=1;i<=n;i++) { for(j=1+n;j<=m+n;j++) { if(i!=j) { double t=sqrt((xs[i]-xs[j])*(xs[i]-xs[j]) + (ys[i]-ys[j])*(ys[i]-ys[j])); if(t/v<=s) map[i][j]=1; } } } int ans=pipei(); printf("%d\n",n-ans); } return 0;}
0 0
- POJ-2536 Gopher II
- poj 2536 Gopher II
- POJ-2536-Gopher II
- POJ 2536 Gopher II
- POJ 2536 Gopher II
- poj 2536 Gopher II
- poj 2536 -- Gopher II (匈牙利)
- POJ 2536 Gopher II 笔记
- zoj 1882 || poj 2536 Gopher II
- POJ 2536 Gopher II 二分匹配
- POJ 2536 Gopher II 简单最大流
- 【POJ】2536 Gopher II 二分匹配
- POJ-2536—Gopher II(二分图)
- POJ 2536 - Gopher II(二分图匹配)
- poj 2536 Gopher II 最大匹配
- poj 2536 Gopher II 最大匹配
- POJ 2536 Gopher II 二分图匹配
- 【二分图】poj 2536 Gopher II
- 动态库的链接和链接选项-L,-rpath-link,-rpath
- 臊子面的做法
- Hrbustoj1376 能量项链 简单区间DP
- 美味臊子面
- tyvj p1001- 第K极值
- POJ 2536 Gopher II
- 对象初始化过程分析
- tyvj p1002- 谁拿了最多奖学金
- 最近圆对
- 上汤丝瓜
- 2014/08/16——VJ/OJ时好时坏,why?
- UNIX环境高级编程复习——文件和目录(5)
- 我是怎样搭建wordpress博客的
- cheap oakleys ABim gIu0 zMpf