Gopher II
Time Limit: 2000MS   Memory Limit: 65536K
Total 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.

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

——————————————————————————————————

题目的意思是有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 long
const 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;
}

POJ2536 Gopher II(二分图最大匹配)的更多相关文章

  1. 2018.07.06 POJ2536 Gopher II(二分图匹配)

    Gopher II Time Limit: 2000MS Memory Limit: 65536K Description The gopher family, having averted the ...

  2. POJ2536 Gopher II【二分图最大匹配】

    题目链接: http://poj.org/problem? id=2536 题目大意: 有N仅仅鼹鼠和M个洞穴,假设鼹鼠在S秒内不可以跑到洞穴,就会被老鹰捉住吃掉. 鼹鼠跑的速度为V米/秒. 已知一个 ...

  3. 无题 II 二分图最大匹配

    题目描述 这是一个简单的游戏,在一个n*n的矩阵中,找n个数使得这n个数都在不同的行和列里并且要求这n个数中的最大值和最小值的差值最小. Input 输入一个整数T表示T组数据. 对于每组数据第一行输 ...

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

    Gopher II Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 6675   Accepted: 2732 Descrip ...

  5. 二分图最大匹配(匈牙利算法) UVA 10080 Gopher II

    题目传送门 /* 匈牙利算法:这题比UVA_670简单,注意是要被吃的鼠的最少个数,套模板 */ #include <cstdio> #include <algorithm> ...

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

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

  7. POJ2536(二分图最大匹配)

    Gopher II Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 8504   Accepted: 3515 Descrip ...

  8. POJ 2226二分图最大匹配

    匈牙利算法是由匈牙利数学家Edmonds于1965年提出,因而得名.匈牙利算法是基于Hall定理中充分性证明的思想,它是二部图匹配最常见的算法,该算法的核心就是寻找增广路径,它是一种用增广路径求二分图 ...

  9. POJ2239 Selecting Courses(二分图最大匹配)

    题目链接 N节课,每节课在一个星期中的某一节,求最多能选几节课 好吧,想了半天没想出来,最后看了题解是二分图最大匹配,好弱 建图: 每节课 与 时间有一条边 #include <iostream ...

随机推荐

  1. Android Studio 解析json文件出现中文乱码解决方法

    作为一个Android开发初学者,好不容易找到解决方法,跟大家分享一下, 其实很简单,只要保持服务器上的文件(date2.json)与软件的编码方式一样就行. 我用的Android Studio是ut ...

  2. Informatica_(6)性能调优

    六.实战汇总31.powercenter 字符集 了解源或者目标数据库的字符集,并在Powercenter服务器上设置相关的环境变量或者完成相关的设置,不同的数据库有不同的设置方法: 多数字符集的问题 ...

  3. ES6 WeakMap和WeakSet的使用场景

    JavaScript垃圾回收是一种内存管理技术.在这种技术中,不再被引用的对象会被自动删除,而与其相关的资源也会被一同回收. Map和Set中对象的引用都是强类型化的,并不会允许垃圾回收.这样一来,如 ...

  4. 高级数据库技术SQL

  5. windows下git的使用方法(码云)

    这表文章主要是用了可视化操作: 使用命令行操作:https://www.cnblogs.com/mswyf/p/9370238.html 一.安装Git Bash 为了在windows下使用Git,我 ...

  6. holiday(假期)_题解

    holiday(假期) —— 一道妙题(codevs3622)   Description 经过几个月辛勤的工作,FJ 决定让奶牛放假.假期可以在1…N 天内任意选择一段(需要连续),每一天都有一个享 ...

  7. TortoiseSVN Project Monitor使用

    今天下载了TortoiseSVN Project Monitor,要把一个项目导入 name一直没有输入,一直导入不成功,点击了ok也不给提示,切记要写项目Name啊! 在使用svncheckout时 ...

  8. mysql bigint ,int , smallint,tinyint 的范围

    bigint  8字节 64位 int 4字节 32位 smallint 2字节 16位 tinyint 1字节8位 .. 范围  -128 到 127  , 如果是无符号 ,则返回 位 0-255 ...

  9. js对象通过属性路径获取属性值 - getPropByPath

    function getPropByPath(obj, path) { let tempObj = obj; path = path.replace(/\[(\w+)\]/g, '.$1'); pat ...

  10. Python之字符串基本操作

    #!/usr/bin/env python#-*-coding utf8-*-#Author:caojininfo = { 'stu1001': 'caojin', 'stu1002': 'zhaom ...