POJ2536 Gopher II(二分图最大匹配)
来源:互联网 发布:中国流动人口数据 编辑:程序博客网 时间:2024/05/16 13:01
Gopher II
Time Limit: 2000MS Memory Limit: 65536KTotal Submissions: 9005 Accepted: 3724
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
Source
Waterloo local 2001.01.27
——————————————————————————————————
题目的意思是有n只鼹鼠m个洞,每个洞可以容纳一只鼹鼠,给出坐标和移动速度,问t秒后有多少只不在洞里
思路:把t秒鼹鼠能跑到的洞连一条边,然后跑最大二分图匹配
#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <cmath>#include <algorithm>#include <queue>#include <vector>#include <set>#include <stack>#include <map>#include <climits>using namespace std;#define LL long longconst int INF = 0x3f3f3f3f;const int MAXN=1000;int uN,vN; //u,v数目int g[MAXN][MAXN];//编号是0~n-1的int linker[MAXN];bool used[MAXN];struct point{ double x,y;} a[105],b[105];bool dfs(int u){ int v; for(v=0; v<vN; v++) if(g[u][v]&&!used[v]) { used[v]=true; if(linker[v]==-1||dfs(linker[v])) { linker[v]=u; return true; } } return false;}int hungary(){ int res=0; int u; memset(linker,-1,sizeof(linker)); for(u=0; u<uN; u++) { memset(used,0,sizeof(used)); if(dfs(u)) res++; } return res;}int main(){ int n,m,v,t; while(~scanf("%d%d%d%d",&n,&m,&v,&t)) { memset(g,0,sizeof g); for(int i=0; i<n; i++) scanf("%lf%lf",&a[i].x,&a[i].y); for(int i=0; i<m; i++) scanf("%lf%lf",&b[i].x,&b[i].y); for(int i=0; i<n; i++) for(int j=0; j<m; j++) { if((a[i].x-b[j].x)*(a[i].x-b[j].x)+(a[i].y-b[j].y)*(a[i].y-b[j].y)<=1.0*v*t*v*t) g[i][j]=1; } uN=n,vN=m; printf("%d\n",n-hungary()); } return 0;}
阅读全文
0 0
- POJ2536 Gopher II【二分图最大匹配】
- POJ2536 Gopher II(二分图最大匹配)
- Gopher II(二分图最大匹配)
- 二分图最大匹配--poj2536
- 【二分图+最大匹配】北大 poj 2536 Gopher II
- ZOJ 1882 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(二分图最大匹配,构图)
- POJ 2536 Gopher II(二分图最大匹配)
- POJ 2536 Gopher II(二分图最大匹配)
- POJ-2536 Gopher II(二分图最大匹配)
- 方差、标准差、均方差、均方误差、均方根误差、标准误差
- JDBC
- STM32 输入捕获的脉冲宽度及频率计算
- 重载和重写
- linux下通过C语言读取BMP格式图片,在文本终端显示该图片
- POJ2536 Gopher II(二分图最大匹配)
- 关于解决No service of type Factory available in ProjectScopeServices的错误
- ORACLE实现Job定时计划任务
- Linux定时任务crond和crondtab
- python3爬取聚美优品多进程入库mongo
- MFC内存读写CMemFile类的使用
- 进制转换
- 先锋机器人走到目标点和走四方形
- LeetCode练习-数组-palindrome-number