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. 【摘抄】meta系列用法总结【持续更新中】

    meta标签分两大部分:HTTP标题信息(HTTP-EQUIV)和页面描述信息(NAME). ★页面描述信息NAME变量  name是描述网页的,对应于Content(网页内容),以便于搜索引擎机器人 ...

  2. find和xargs

    find 命令的一般形式为 find pathname -options [-print -exec -ok] 让我们来看看该命令的参数: pathname find命令所查找的目录路径.例如用.来表 ...

  3. Java 7 命令/工具 jcmd 使用详细解释

    常见功能 列出 Java 进程 PID 以及 名称 列出进程的 thread dump 得到进程的 heap dump 得到进程的 JVM 参数 具体如下: 列出 Java 进程 PID 以及 名称 ...

  4. 通过NORFLASH中的uboot烧写uboot到nandFlash

    在mini2440的教程中,在构建nandflash系统的时候是首先通过supervivi借助dnw烧写uboot.bin到nand flash 第零块, 由于我使用的是64位操作系统,usb驱动没安 ...

  5. Hbase之取出行数据指定部分+版本控制(类似MySQL的Limit)

    import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.CellScanner; import org. ...

  6. C++ Primer 第三章 标准库类型string运算

    1. 标准库类型 string string表示可变长的字符序列,使用string必须首先包含string头文件.如何初始化类的对象是由类本身决定的. int n; string s1;//默认初始化 ...

  7. 栈 - 从零开始实现by C++

    参考链接:数据结构探险-栈篇 学了队列之后,栈就很简单了,换汤不换药.   栈 栈的模型 后进先出(电梯,进制转换,括号的匹配检测)   栈的基本元素 栈顶,栈底(一般很少用到),栈容量,栈长度 注意 ...

  8. An unknown server-side error occurred while processing the command.处理

    在调用resetAPP()时,报错:An unknown server-side error occurred while processing the command. 怎么解决呢?请看: 额,Ap ...

  9. dom event无法获取问题

    下列几种情况下无法获取到event,ff浏览器没测试. 1.a标签href调用的js事件 2.调用parent中事件,即子窗口调用父窗口页面中js 3....

  10. 在腾讯云上创建您的SQL Cluster(3)

    版权声明:本文由李斯达原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/250 来源:腾云阁 https://www.qclo ...