Gopher II
Time Limit: 2000MS   Memory Limit: 65536K
Total Submissions: 6345   Accepted: 2599

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

Source

最大独立集:

 //200K    47MS    C++    1200B    2014-06-10 07:43:56
#include<stdio.h>
#include<string.h>
#include<math.h>
#define N 105
struct node{
double x,y;
}gopher[N],hole[N];
int g[N][N];
int match[N];
int vis[N];
int n,m;
double dist(node a,node b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
int dfs(int u)
{
for(int i=;i<m;i++)
if(!vis[i] && g[u][i]){
vis[i]=;
if(match[i]==- || dfs(match[i])){
match[i]=u;
return ;
}
}
return ;
}
int hungary()
{
int ret=;
memset(match,-,sizeof(match));
for(int i=;i<n;i++){
memset(vis,,sizeof(vis));
ret+=dfs(i);
}
return ret;
}
int main(void)
{
double s,v;
while(scanf("%d%d%lf%lf",&n,&m,&s,&v)!=EOF)
{
for(int i=;i<n;i++)
scanf("%lf%lf",&gopher[i].x,&gopher[i].y);
for(int i=;i<m;i++)
scanf("%lf%lf",&hole[i].x,&hole[i].y);
memset(g,,sizeof(g));
for(int i=;i<n;i++)
for(int j=;j<m;j++)
if(dist(gopher[i],hole[j])/v<s)
g[i][j]=;
printf("%d\n",n-hungary());
}
return ;
}

poj 2536 Gopher II (二分匹配)的更多相关文章

  1. POJ 2536 Gopher II(二分图的最大匹配)

    题目链接:http://poj.org/problem?id=2536 题意:已知有n仅仅老鼠的坐标,m个洞的坐标,老鼠的移动速度为V,S秒以后有一仅仅老鹰要吃老鼠,问有多少个老鼠被吃. 非常明晰,二 ...

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

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

  3. POJ 2536 Gopher II

    二分图的最大匹配 地鼠内部和地鼠洞内部都是没有边相连的,那么就可以看成一个二分图.地鼠如果可以跑到那个地鼠洞,就连一条边,然后跑二分图的最大匹配,最后地鼠的数量减去最大匹配数就是答案. #includ ...

  4. POJ 2536 Gopher II(二分图最大匹配)

    题意: N只地鼠M个洞,每只地鼠.每个洞都有一个坐标. 每只地鼠速度一样,对于每只地鼠而言,如果它跑到某一个洞的所花的时间小于等于S,它才不会被老鹰吃掉. 规定每个洞最多只能藏一只地鼠. 问最少有多少 ...

  5. poj 3057(bfs+二分匹配)

    题目链接:http://poj.org/problem?id=3057 题目大概意思是有一块区域组成的房间,房间的边缘有门和墙壁,'X'代表墙壁,'D'代表门,房间内部的' . '代表空区域,每个空区 ...

  6. POJ 1469(裸二分匹配)

    COURSES Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 18993   Accepted: 7486 Descript ...

  7. poj 2239 Selecting Courses (二分匹配)

    Selecting Courses Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8316   Accepted: 3687 ...

  8. poj 2536 GopherII(二分图匹配)

    Description The gopher family, having averted the canine threat, must face a new predator. The are n ...

  9. [POJ 2536] Gopher ||

    [题目链接] http://poj.org/problem?id=2536 [算法] 匈牙利算法解二分图最大匹配 [代码] #include <algorithm> #include &l ...

随机推荐

  1. python百分比数比较大小

    python是无法识别百分比的,估计你的百分比是string,所以需要转成int # !/usr/bin/python3.4 # -*- coding: utf-8 -*- # 百分数转为int de ...

  2. Java入门教程总目录

    Java入门教程总目录 持续更新中... 1.Java常识汇总 2.Java框架对比 3.Java技术路线 4.Java编码规范 5.Java环境变量配置 6.枚举 7.操作符 12.定时任务

  3. Java 异步处理简单实践

    Java 异步处理简单实践 http://www.cnblogs.com/fangfan/p/4047932.html 同步与异步 通常同步意味着一个任务的某个处理过程会对多个线程在用串行化处理,而异 ...

  4. C++编程命名规则(转载)

    原文地址:http://www.cnblogs.com/ggjucheng/archive/2011/12/15/2289291.html 如果想要有效的管理一个稍微复杂一点的体系,针对其中事物的一套 ...

  5. Linux查看系统资源使用情况(转)

    概述: 用 'top -i' 看看有多少进程处于 Running 状态,可能系统存在内存或 I/O 瓶颈,用 free 看看系统内存使用情况,swap 是否被占用很多,用 iostat 看看 I/O ...

  6. java 线程的命名

    //线程的命名 class xc2 extends Thread{ public void run(){ for(int i=0;i<20;i++){ //Thread.currentThrea ...

  7. Shell脚本中执行sql语句操作mysql

    对于自动化运维,诸如备份恢复之类的,DBA经常需要将SQL语句封装到shell脚本.本文描述了在Linux环境下mysql数据库中,shell脚本下调用sql语句的几种方法,供大家参考.对于脚本输出的 ...

  8. 分享一下自己正在使用的sublime text里的插件

    真的回头想想要不是当时一个学姐给我介绍了这个编辑器,我可能还是那种迫不得已了不得不编程了才会去敲代码的,可能还是一只不喜欢编程的程序员.可是自从用了这款编辑器,我的世界仿佛都被改变了.天呐,整天忍不住 ...

  9. winform建立非矩形窗体

    非规则窗体可能会需要加的功能代码: 1:因为没有了最上边的标题栏,所以需要加窗体鼠标拖动功能,在Form里面加如下代码: #region 移动窗体 // 移动窗体 const int WM_NCLBU ...

  10. LR11-更改licence

    准备工作: 超级licence 6.5w:AEACFSJI-YJKJKJJKEJIJD-BCLBR AEACFSJI-YJKJKJJKEJIJD-BCLBR 操作步骤: 1.网上下载lr删除注册表工具 ...