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

题目大意,有一块地上面有N只老鼠和M个只能装的下一只老鼠的老鼠洞,老鼠和老鼠洞的坐标已给出,老鹰在S秒后来到,老鼠的速度全部为V,问最少有多少老鼠来不及进洞
简单的二分图匹配算法,直接贴出代码:
#include<iostream>
#include<string.h>
#include<cmath>
using namespace std;
int map[][],v[];
double x[],y[],xx,yy;
int match[];
int N,M,S,V;
double disIsOK(double x1,double y1,double x2,double y2){
return S*V>=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
int dfs(int ii){
for(int i=;i<=N;i++){
if(map[i][ii]&&!v[i]){
v[i]=;
if(match[i]==||dfs(match[i])){
match[i]=ii;return ;
}
}
}
return ;
}
int main(){
while(cin>>N>>M>>S>>V){
memset(map,,sizeof(map));
memset(match,,sizeof(match));
for(int i=;i<=N;i++){
cin>>x[i]>>y[i];
}
for(int i=;i<=M;i++){
cin>>xx>>yy;
for(int j=;j<=N;j++){
if(disIsOK(x[j],y[j],xx,yy)){
map[j][i]=;
}
}
}
int res=;
for(int i=;i<=M;i++){
memset(v,,sizeof(v));
if(dfs(i))res++;
}
cout<<N-res<<endl;
}
return ;
}

结果截图:

												

poj 2536 GopherII(二分图匹配)的更多相关文章

  1. POJ 1274 裸二分图匹配

    题意:每头奶牛都只愿意在她们喜欢的那些牛栏中产奶,告诉每头奶牛愿意产奶的牛棚编号,求出最多能分配到的牛栏的数量. 分析:直接二分图匹配: #include<stdio.h> #includ ...

  2. POJ 2446 Chessboard (二分图匹配)

    题意 在一个N*M的矩形里,用1*2的骨牌去覆盖该矩形,每个骨牌只能覆盖相邻的两个格子,问是否能把每个格子都盖住.PS:有K个孔不用覆盖. 思路 容易发现,棋盘上坐标和为奇数的点只会和坐标和为偶数的点 ...

  3. POJ 3041 Asteroids 二分图匹配

    以行列为点建图,每个点(x,y) 对应一条边连接x,y.二分图的最小点覆盖=最大匹配 //#pragma comment(linker, "/STACK:1024000000,1024000 ...

  4. Poj(1274),二分图匹配

    题目链接:http://poj.org/problem?id=1274 The Perfect Stall Time Limit: 1000MS   Memory Limit: 10000K Tota ...

  5. TTTTTTTTTTTTT poj 3057 Evacuation 二分图匹配+bfs

    题意:见挑战230页 #include <iostream> #include <cstdio> #include <cstring> #include <c ...

  6. POJ 3057 Evacuation 二分图匹配

    每个门每个时间只能出一个人,那就把每个门拆成多个,对应每个时间. 不断增加时间,然后增广,直到最大匹配. //#pragma comment(linker, "/STACK:10240000 ...

  7. POJ 2536 Gopher II (ZOJ 2536) 二分图匹配

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1882 http://poj.org/problem?id=2536 题目大 ...

  8. POJ 2195 Going Home (带权二分图匹配)

    POJ 2195 Going Home (带权二分图匹配) Description On a grid map there are n little men and n houses. In each ...

  9. POJ 2289 Jamie's Contact Groups / UVA 1345 Jamie's Contact Groups / ZOJ 2399 Jamie's Contact Groups / HDU 1699 Jamie's Contact Groups / SCU 1996 Jamie's Contact Groups (二分,二分图匹配)

    POJ 2289 Jamie's Contact Groups / UVA 1345 Jamie's Contact Groups / ZOJ 2399 Jamie's Contact Groups ...

随机推荐

  1. Fatal error compiling: 无效的目标发行版: 1.8 -> [Help 1] (zhuan)

    http://blog.csdn.net/z18137017273/article/details/53033613 ***************************************** ...

  2. Python 调用自定义包

    创建包 # mkdir -p /python/utils # touch /python/utils/__init__.py # vi /python/utils/Log.pyimport timed ...

  3. ORACLE CentOS5.6安装

    1 准备 CentOS 5.6企业版 oracle11g fs 安装.安装环境为vmware虚拟机.另外,本安装文档非常简洁,但关键步骤都指出来了,其他的都是默认选择,遇到不知该如何选择的操作或者问题 ...

  4. windows redis:Uncaught exception 'RedisException' with message 'Redis server went away'

    window-exe-redis-2.8.12服务,当你复制好php_igbinary.dll,php_redis.dll时候,你运行redis报错:Fatal error: Uncaught exc ...

  5. Tomcat的测试页打开空白页的解决方法

    win7下安装tomcat 9简要步骤: 1.下载Tomcat 到Tomcat官网https://tomcat.apache.org/download-90.cgi下载Tomcat 9.0>Co ...

  6. HTML5自学笔记[ 10 ]简单的购物车拖拽

    用html5拖拽功能实现了一个简单的购物车,样式简陋,得学学画画提高下审美了T^T: <!doctype html> <html> <head> <meta ...

  7. !important css样式

    重要性 我们在做网页代码的时,有些特殊的情况需要为某些样式设置具有最高权值,怎么办?这时候我们可以使用!important来解决. 如下代码: p{color:red!important;} p{co ...

  8. 工程目录 Java/Web/Maven

    jar包和war包的区别 war是一个web模块,其中需要包括WEB-INF,是可以直接运行的WEB模块.而jar一般只是包括一些class文件,在声明了Main_class之后是可以用java命令运 ...

  9. hdu ---(4517)小小明系列故事——游戏的烦恼(Dp)

    小小明系列故事——游戏的烦恼 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)To ...

  10. jquery iframe高度自适应

    $(document).ready(function () { $("#test").load(function () { var thisheight = $(this).con ...