openjudge GoperII
来源:互联网 发布:语音数据统计校对员 编辑:程序博客网 时间:2024/06/11 13:47
1538:Gopher II
- 查看
- 提交
- 统计
- 提问
- 总时间限制:
- 2000ms
- 内存限制:
- 65536kB
- 描述
- 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 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 consists of a single line for each case, giving the number of vulnerable gophers.
- 样例输入
2 2 5 101.0 1.02.0 2.0100.0 100.020.0 20.0
- 样例输出
1
- 题目大意:N只老鼠,M个洞,每个洞只能容纳一只老鼠,老鼠有S秒的时间逃跑,每只老鼠的速度均为V,问时间结束后至少有多少只老鼠会有危险
Waterloo local 2001.01.27
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int f[110][110],n,m,i,j,s,v,num;
double x1[110],y11[110],x2[110],y2[110];
int used[110],hole[110];
bool find(int x)
{
for (int k=1;k<=m;k++)
{
if (f[x][k]==1&&used[k]==0)
{
used[k]=1;
if (find(hole[k])||hole[k]==0)
{
hole[k]=x;
return true;
}
}
}
return false;
}
int main()
{
while(scanf("%d%d%d%d",&n,&m,&s,&v)==4)
{
memset(f,0,sizeof(f));
memset(hole,0,sizeof(hole));
for (i=1;i<=n;i++)
scanf("%lf%lf",&x1[i],&y11[i]);
for (i=1;i<=m;i++)
scanf("%lf%lf",&x2[i],&y2[i]);
for (i=1;i<=n;i++)
for (j=1;j<=m;j++)
{
double len=sqrt(fabs(x1[i]-x2[j])*fabs(x1[i]-x2[j])+fabs(y11[i]-y2[j])*fabs(y11[i]-y2[j]));
if (len<=s*v)
{
f[i][j]=1;
}
}
num=0;
for (i=1;i<=n;i++)
{
memset(used,0,sizeof(used));
if (find(i)) num++;
}
printf("%d\n",n-num);
}
} //匈牙利算法二分图的最大匹配
- openjudge GoperII
- OpenJudge
- [OpenJudge]胡
- OPENJUDGE LIST
- OPENJUDGE SET
- openjudge 迷宫
- openjudge 2764
- 【openjudge】Minecraft
- 【openjudge】登山
- 【openjudge】股票买卖
- 【openjudge】大盗阿福
- openjudge divisibility
- 【openjudge】糖果
- openjudge 糖果
- openjudge 马走日
- openjudge 仙岛求药
- 【openjudge】金银岛
- 【openjudge】迷宫
- 音乐播放器之--错误状态下调用导致的异常
- mipmap和drawable区别
- Bmob中的几种查询方法
- android中卡号输入框控件(每四位用空格分隔)(解决输入法跳转的问题)
- 体胖还需勤锻炼,人丑就要多读书
- openjudge GoperII
- Block中weakSelf的使用
- VS2010动态库生成及应用问题
- 网红是完全从草根中产 的一群明星
- windbg kp kb 命令测试
- 关于JavaScript原型对象的理解
- xcode用户界面概述
- 初学web开发需要掌握哪些知识
- 测试人员的问题分析能力