题意:n只地鼠,m个地鼠洞,地鼠必须以v的速度在s秒内钻进洞且每个洞仅能容纳一只地鼠,问最少有几只地鼠会被老鹰吃掉。

分析:最大匹配问题,将s秒内地鼠能够跑到的洞与该地鼠连成一条边,在最后得到的图中使用匈牙利。

代码:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
#define Del(x,y) memset(x,y,sizeof(x)) double xx[],yy[];
int n,m;
int map[][],vis[],link[]; bool dfs(int x)
{
for(int i=; i<=m; i++)
if(map[x][i]==&&vis[i]==)
{
vis[i]=;
if(link[i]==-||dfs(link[i]))
{
link[i]=x;
return true;
}
}
return false;
} void solve()
{
int ans=;
Del(link,-);
for(int i=; i<=n; i++)
{
Del(vis,);
if(dfs(i))
ans++;
}
printf("%d\n",n-ans);
} double dis(int i,double a,double b)
{
return sqrt((xx[i]-a)*(xx[i]-a)+(yy[i]-b)*(yy[i]-b));
} int main()
{
int s,v;
double p,q;
while(~scanf("%d%d%d%d",&n,&m,&s,&v))
{
for(int i=; i<=n; i++)
scanf("%lf%lf",&xx[i],&yy[i]);
Del(map,);
for(int i=; i<=m; i++)
{
scanf("%lf%lf",&p,&q);
for(int j=; j<=n; j++)
{
if(dis(j,p,q)<=(s*v))
map[j][i]=;
}
}
solve();
}
return ;
}

POJ_2536_Gopher II的更多相关文章

  1. Leetcode 笔记 113 - Path Sum II

    题目链接:Path Sum II | LeetCode OJ Given a binary tree and a sum, find all root-to-leaf paths where each ...

  2. Leetcode 笔记 117 - Populating Next Right Pointers in Each Node II

    题目链接:Populating Next Right Pointers in Each Node II | LeetCode OJ Follow up for problem "Popula ...

  3. 函数式Android编程(II):Kotlin语言的集合操作

    原文标题:Functional Android (II): Collection operations in Kotlin 原文链接:http://antonioleiva.com/collectio ...

  4. 统计分析中Type I Error与Type II Error的区别

    统计分析中Type I Error与Type II Error的区别 在统计分析中,经常提到Type I Error和Type II Error.他们的基本概念是什么?有什么区别? 下面的表格显示 b ...

  5. hdu1032 Train Problem II (卡特兰数)

    题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能.    (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...

  6. [LeetCode] Guess Number Higher or Lower II 猜数字大小之二

    We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to gues ...

  7. [LeetCode] Number of Islands II 岛屿的数量之二

    A 2d grid map of m rows and n columns is initially filled with water. We may perform an addLand oper ...

  8. [LeetCode] Palindrome Permutation II 回文全排列之二

    Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empt ...

  9. [LeetCode] Permutations II 全排列之二

    Given a collection of numbers that might contain duplicates, return all possible unique permutations ...

随机推荐

  1. Lua中..和#运算符的用法

    Lua中..和#运算符的用法 样例 试试以下的样例就明确了在Lua编程语言提供的其它运算符: a = "Hello " b = "World" print(&q ...

  2. web网站架构演变过程

    我们以javaweb为例,来搭建一个简单的电商系统,看看这个系统可以如何一步步演变.   该系统具备的功能:   用户模块:用户注册和管理 商品模块:商品展示和管理 交易模块:创建交易和管理 阶段一. ...

  3. mysql导出整个数据库

    mysql导出整个数据库 mysqldump -hhostname -uusername -ppassword databasename > backupfile.sql mysqldump - ...

  4. hdu 4778 Gems Fight!

    第一次写状压dp-- 题意:http://blog.csdn.net/dyx404514/article/details/15506601 状压dp+博弈吧-- #include<iostrea ...

  5. Tomcat 隐藏Server Name

    隐藏Http请求中的Header ServerName 方法一 在tomcat/lib/tomcat-coyote.jar中 下面两个文件 org/apache/coyote/http11/Const ...

  6. YTU 2504: 蚂蚁感冒

    2504: 蚂蚁感冒 时间限制: 1 Sec  内存限制: 128 MB 提交: 273  解决: 118 题目描述 长100厘米的细长直杆子上有n只蚂蚁.它们的头有的朝左,有的朝右.每只蚂蚁都只能沿 ...

  7. PyCharm创建文件时自动添加头文件

    依次找到以下路径: File->settings->Editor->File and Code Templates->Python Script  #!/usr/bin/env ...

  8. fck 属性配置大全

    优化FCKeditor文件夹和文件: 下载FCKeditor并解压之后,会产生_samples和 editor两个文件夹和几个文件,全部删除以_开头的文件夹和文件,因为这些都是FCKeditor的一些 ...

  9. bzoj2679: [Usaco2012 Open]Balanced Cow Subsets(折半搜索)

    2679: [Usaco2012 Open]Balanced Cow Subsets Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 462  Solv ...

  10. [App Store Connect帮助]四、添加 App 图标、App 预览和屏幕快照(6)设置 App 预览海报帧

    App 预览海报帧仅在 App 状态为可编辑时,才能被编辑. 必要职能:“帐户持有人”职能.“管理”职能.“App 管理”职能或“营销”职能.请参见职能权限. 在首页上,点按“我的 App”,选择您的 ...