http://www.lydsy.com/JudgeOnline/problem.php?id=2642

题意:

n个瞭望台,形成一个凸n边形。这些瞭望台的保护范围是这个凸包内的任意点。

敌人进攻时,会炸毁一些瞭望台,使得总部暴露在新的保护范围之外。

选择一个点作为总部,使得敌人在任何情况下需要炸坏的瞭望台数目尽量多

任何情况指,假设需炸毁m个,无论炸毁哪m个,剩下的瞭望台都不能保护总部

输出这个数目

凸壳上的点顺时针输入

若敌人只能炸一次,那么总部应选在

所有点i+2到点i组成的有向直线的左侧——半平面交

若敌人能炸两次,那么炸连续的两个点更优

炸毁连续的两个,可以使得到的半平面的左侧尽量靠边

这样交集更容易为空

同理,炸毁k个也是炸毁连续的k个

所以二分炸毁次数k,

判断所有i+k+1和点i构成的有向直线表示的半平面有没有交集即可

#include<cmath>
#include<cstdio>
#include<iostream>
#include<algorithm> using namespace std; #define N 50001 typedef long long LL; const double eps=1e-; struct Point
{
double x,y; Point(double x=,double y=):x(x),y(y) {}
}; typedef Point Vector; Point P[N]; Vector operator + (Vector A,Vector B) { return Vector(A.x+B.x,A.y+B.y); }
Vector operator - (Vector A,Vector B) { return Vector(A.x-B.x,A.y-B.y); }
Vector operator * (Vector A,double b) { return Vector(A.x*b,A.y*b); } struct Line
{
Point P;
Vector v;
double ang; Line() {}
Line(Point P,Vector v) : P(P),v(v) { ang=atan2(v.y,v.x); } bool operator < (Line L) const
{
return ang<L.ang;
}
}; Line L[N]; void read(int &x)
{
x=; int f=; char c=getchar();
while(!isdigit(c)) { if(c=='-') f=-; c=getchar(); }
while(isdigit(c)) { x=x*+c-''; c=getchar(); }
x*=f;
} double Cross(Vector A,Vector B)
{
return A.x*B.y-A.y*B.x;
} bool OnLeft(Line L,Point p)
{
return Cross(L.v,p-L.P)>;
} Point GetIntersection(Line a,Line b)
{
Vector u=a.P-b.P;
double t=Cross(b.v,u)/Cross(a.v,b.v);
return a.P+a.v*t;
} bool HalfplaneIntersection(Line *L,int n)
{
// sort(L,L+n); 顺时针输入的点,本来就按极角排好序了
Point *p=new Point[n];
Line *q=new Line[n];
int first,last;
q[first=last=]=L[];
for(int i=;i<n;++i)
{
while(first<last && !OnLeft(L[i],p[last-])) last--;
while(first<last && !OnLeft(L[i],p[first])) first++;
q[++last]=L[i];
if(fabs(Cross(q[last].v,q[last-].v))<eps)
{
last--;
if(OnLeft(q[last],L[i].P)) q[last]=L[i];
}
if(first<last) p[last-]=GetIntersection(q[last],q[last-]);
}
while(first<last && !OnLeft(q[first],p[last-])) last--;
return last-first>;
} bool check(int n,int k)
{
int m=;
for(int i=;i<n;++i) L[m++]=Line(P[i],P[i]-P[(i+k+)%n]);
return !HalfplaneIntersection(L,m);
} int main()
{
int n,x,y;
int l,r,mid,ans=;
while(scanf("%d",&n)!=EOF)
{
for(int i=;i<n;++i)
{
read(x); read(y);
P[i]=Point(x,y);
}
ans=n-;
l=; r=n-;
while(l<=r)
{
mid=l+r>>;
if(check(n,mid)) ans=mid,r=mid-;
else l=mid+;
}
cout<<ans<<'\n';
}
}

bzoj千题计划210:bzoj2642 | Poj3968 | UVALive 4992| hdu 3761 Jungle Outpost的更多相关文章

  1. bzoj千题计划300:bzoj4823: [Cqoi2017]老C的方块

    http://www.lydsy.com/JudgeOnline/problem.php?id=4823 讨厌的形状就是四联通图 且左右各连一个方块 那么破坏所有满足条件的四联通就好了 按上图方式染色 ...

  2. bzoj千题计划196:bzoj4826: [Hnoi2017]影魔

    http://www.lydsy.com/JudgeOnline/problem.php?id=4826 吐槽一下bzoj这道题的排版是真丑... 我还是粘洛谷的题面吧... 提供p1的攻击力:i,j ...

  3. bzoj千题计划280:bzoj4592: [Shoi2015]脑洞治疗仪

    http://www.lydsy.com/JudgeOnline/problem.php?id=4592 注意操作1 先挖再补,就是补的范围可以包含挖的范围 SHOI2015 的题 略水啊(逃) #i ...

  4. bzoj千题计划219:bzoj1568: [JSOI2008]Blue Mary开公司

    http://www.lydsy.com/JudgeOnline/problem.php?id=1568 写多了就觉着水了... #include<cstdio> #include< ...

  5. bzoj千题计划177:bzoj1858: [Scoi2010]序列操作

    http://www.lydsy.com/JudgeOnline/problem.php?id=1858 2018 自己写的第1题,一遍过 ^_^ 元旦快乐 #include<cstdio> ...

  6. bzoj千题计划317:bzoj4650: [Noi2016]优秀的拆分(后缀数组+差分)

    https://www.lydsy.com/JudgeOnline/problem.php?id=4650 如果能够预处理出 suf[i] 以i结尾的形式为AA的子串个数 pre[i] 以i开头的形式 ...

  7. bzoj千题计划304:bzoj3676: [Apio2014]回文串(回文自动机)

    https://www.lydsy.com/JudgeOnline/problem.php?id=3676 回文自动机模板题 4年前的APIO如今竟沦为模板,,,╮(╯▽╰)╭,唉 #include& ...

  8. bzoj千题计划292:bzoj2244: [SDOI2011]拦截导弹

    http://www.lydsy.com/JudgeOnline/problem.php?id=2244 每枚导弹成功拦截的概率 = 包含它的最长上升子序列个数/最长上升子序列总个数 pre_len ...

  9. bzoj千题计划278:bzoj4590: [Shoi2015]自动刷题机

    http://www.lydsy.com/JudgeOnline/problem.php?id=4590 二分 这么道水题 没long long WA了两发,没判-1WA了一发,二分写错WA了一发 最 ...

随机推荐

  1. 阿里云ECS 固定带宽变为按量付费的方式

    阿里云ECS 固定带宽变为按量付费的方式 阿里云控制台 2.升降配置-降低配置-降低至最低配置 3.为按量带宽设置一个峰值,例如100M. 4.过几分钟,就自动变为按量付费的带宽了.

  2. Category Theory: 01 One Structured Family of Structures

    Category Theory: 01 One Structured Family of Structures 这次看来要放弃了.看了大概三分之一.似乎不能够让注意力集中了.先更新吧. 群的定义 \( ...

  3. webpack 支持的模块方法

    在webpack中支持的模块语法风格有:ES6,commonJS和AMD ES6风格(推荐) 在webpack2中,webpack支持ES6模块语法.这意味着在没有babel等工具处理的情况下你就可以 ...

  4. OAuth 2.0 Salesforce & Azure

    最近在学习Salesforce,浅谈一下 OAuth 2.0 在Salesforce and Azure 之间的应用. 假设有这样一个场景,在Salesforce中需要用到Azure中的一些服务,那么 ...

  5. Ajax实例OR技术原理 转自 (http://blog.csdn.net/evankaka )

    摘要:AJAX即“Asynchronous Javascript And XML”(异步JavaScript和XML),是指一种创建交互式网页应用的网页开发技术.AJAX 是一种用于创建快速动态网页的 ...

  6. 2-Eighteenth Scrum Meeting-20151218

    任务安排 成员 今日完成 明日任务 闫昊 写完学习进度记录的数据库操作  写完学习进度记录的数据库操作 唐彬 编写与服务器交互的代码 和服务器老师交流讨论区后台接口 史烨轩 获取视频url  尝试使用 ...

  7. 第三周:构造一个简单的LINUX系统MENUOS

    吕松鸿 + 原创作品转载请注明出处 + <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 一.Linux内 ...

  8. NetFPGA Demo ——reference_nic_nf1_cml

    NetFPGA Demo --reference_nic_nf1_cml 实验平台 OS:deepin 15.4 开发板:NetFPGA_1G_CML 实验过程 从NetFPGA-1G-CML从零开始 ...

  9. WM_CONCAT和LISTAGG 语法例子

    select to_char(replace(wm_concat(name), ',', '')) from codeitems where setid = 'A018' and ' like cod ...

  10. layout图形化界面看不到内容 Failed to find the style corresponding to the id

    1.问题 在创建新的工程的时候,选择目标SDK为api21,编译SDK为api23.创建出来的layout文件图形化界面中看不到,并且报错: Failed to find the style corr ...