BZOJ1580 : [Usaco2009 Hol]Cattle Bruisers 杀手游戏
以贝茜为参照物,则贝茜固定于原点,每个杀手是一个圆心在某条射线上的圆。
解出每个杀手可以射杀贝茜的时间区间,然后扫描线即可,时间复杂度$O(n\log n)$。
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
int n,r,bx,by,bvx,bvy,x,y,vx,vy,i,m,t,ans;double L,R,inf=1e9;
struct P{double x;int y;P(){}P(double _x,int _y){x=_x,y=_y;}}a[100010];
inline bool cmp(P a,P b){return a.x<b.x;}
inline void getlr(ll a,ll b,ll c){
if(!a){
if(c<=0)L=0,R=inf;else L=R=-inf;
return;
}
ll d=b*b-a*c*4;
if(d<0){L=R=-inf;return;}
L=(-1.0*b-sqrt(d))/2/a,R=(-1.0*b+sqrt(d))/2/a;
if(R<0)L=R=-inf;
if(L<0)L=0;
}
int main(){
scanf("%d%d%d%d%d%d",&n,&r,&bx,&by,&bvx,&bvy);
while(n--){
scanf("%d%d%d%d",&x,&y,&vx,&vy);
x-=bx,y-=by,vx-=bvx,vy-=bvy;
getlr(vx*vx+vy*vy,2*(x*vx+y*vy),x*x+y*y-r*r);
if(R>-1)a[++m]=P(L,1),a[++m]=P(R,-1);
}
sort(a+1,a+m+1,cmp);
for(i=1;i<=m;i++)ans=max(ans,t+=a[i].y);
return printf("%d",ans),0;
}
BZOJ1580 : [Usaco2009 Hol]Cattle Bruisers 杀手游戏的更多相关文章
- 【BZOJ1580】【USACO2009Hol】杀手游戏 计算几何
题目描述 一个平面上有很多个点在运动.给你每个点的初始坐标和每个点的速度,求出最多有多少个点到\(0\)号店的距离同时不超过\(r\). \(n\leq 50000\) 题解 我们先把\(0\)号点平 ...
- [bzoj1582][Usaco2009 Hol]Holiday Painting 节日画画_线段树
Holiday Painting 节日画画 bzoj-1582 Usaco-2009 Hol 题目大意:给定两个n*m的01网格图.q次操作,每次将第二个网格图的子矩阵全部变成0或1,问每一次操作后两 ...
- [bzoj1507][Usaco2009 Hol]Transmission Delay 传输谍延时_动态规划
Transmission Delay 传输谍延时 bzoj-1581 Usaco-2009 Hol 题目大意:题目链接. 注释:略. 想法: 动态规划. 首先我们考虑从后往前dp.(最近好多题都是从后 ...
- [BZOJ1582] [Usaco2009 Hol]Holiday Painting 节日画画(线段树)
传送门 线段树区间修改傻题 #include <cstdio> #include <cstring> #include <iostream> #define N 5 ...
- bzoj AC倒序
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...
- 用 Unity 和 HTC Vive 实现高级 VR 机制(1)
原文:Advanced VR Mechanics With Unity and the HTC Vive Part 1 作者:Eric Van de Kerckhove 译者:kmyhy VR 从来没 ...
- BZOJ3404: [Usaco2009 Open]Cow Digit Game又见数字游戏
3404: [Usaco2009 Open]Cow Digit Game又见数字游戏 Time Limit: 3 Sec Memory Limit: 128 MBSubmit: 47 Solved ...
- 3404: [Usaco2009 Open]Cow Digit Game又见数字游戏
3404: [Usaco2009 Open]Cow Digit Game又见数字游戏 Time Limit: 3 Sec Memory Limit: 128 MBSubmit: 72 Solved ...
- bzoj 2017 [Usaco2009 Nov]硬币游戏 动态规划
[Usaco2009 Nov]硬币游戏 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 431 Solved: 240[Submit][Status] ...
随机推荐
- [codeforces 241]A. Old Peykan
[codeforces 241]A. Old Peykan 试题描述 There are n cities in the country where the Old Peykan lives. The ...
- STL之list容器用法
List 容器 list是C++标准模版库(STL,Standard Template Library)中的部分内容.实际上,list容器就是一个双向链表,可以高效地进行插入删除元素. 使用list容 ...
- 阿里云服务器配置 SVN 服务器与生产站点同步
作为linux的门外汉,一直觊觎svn的方便性,在有台aliyun的情况下,一起来搞搞. 1.环境 阿里云 centos5.5 2.安装svn yum -y install subve ...
- zookeeper 用法和日常运维
本文以ZooKeeper3.4.3版本的官方指南为基础:http://zookeeper.apache.org/doc/r3.4.3/zookeeperAdmin.html,补充一些作者运维实践中的要 ...
- SpringMVC请求处理流程
从web.xml中 servlet的配置开始, 根据servlet拦截的url-parttern,来进行请求转发 Spring MVC工作流程图 图一 图二 Spring工作流程描述 ...
- 深入学习微框架:Spring Boot - NO
http://blog.csdn.net/hengyunabc/article/details/50120001 Our primary goals are: Provide a radically ...
- Lowest Common Ancestor
Given the root and two nodes in a Binary Tree. Find the lowest common ancestor(LCA) of the two nodes ...
- 正则表达式里"-"中划线的使用注意
今天要匹配正则表达式,把非法的字符找出来,开始的写法是这个 [^A-Za-z0-9_.*-+%!],我的目的是把_.*-+%!这7个字符算合法字符,但是发现有许多其他字符也合法了,原来是中划线的位置不 ...
- Mac OS Ruby安装 使用RVM
访问http://www.ruby-lang.org/en/downloads/ 使用第三方工具安装ruby,经过了解,在mac下可以使用macports和rvm安装ruby. 经过实际操作觉得rvm ...
- sysctl命令详解
个人一般sysctl -p 或sysctl -a比较多使用 sysctl配置与显示在/proc/sys目录中的内核参数.可以用sysctl来设置或重新设置联网功能,如IP转发.IP碎片去除以及源路由检 ...