BZOJ 4140 凸包+二进制分组
思路:
$(x_0-x)^2+(y_0-y)^2<=x^2+y^2$
$y>=(-x_0/y_0)x+(x_0^2+y_0^2)/2y0$
这显然就是凸包了
以一个斜率不断向下(上)走 找到第一个接触到的点
离线可以用cdq分治一发 他左边的判一判是不是都符合在圆内
这不能离线就很难搞了
感觉自己代码能力捉鸡 写棵splay估计要调死
强烈安利二进制分组做法
非常强
在log个凸包上 二分一下斜率 判一判 就好了
//By SiriusRen
#include <bits/stdc++.h>
using namespace std;
const int N=;
const double pi=acos(-),eps=1e-;
int n,op,flg,tot,num,top,rec,size[];
struct Point{double x,y;Point(double X=,double Y=):x(X),y(Y){}}jy,lst[N],q[N];
Point operator-(Point a,Point b){return Point(a.x-b.x,a.y-b.y);}
double operator*(Point a,Point b){return a.x*b.y-a.y*b.x;}
bool operator<(Point a,Point b){return a.x==b.x?a.y<b.y:a.x<b.x;}
bool cmp(Point a,Point b){return (a-lst[])*(b-lst[])>-eps;}
vector<Point>vec[];vector<double>ang[];
void Tubao(){
for(int i=;i<=num;i++)if(lst[i]<lst[])swap(lst[],lst[i]);
sort(lst+,lst++num,cmp),top=;
for(int i=;i<=num;i++){
while(top>&&(lst[i]-q[top])*(q[top]-q[top-])>-eps)top--;
q[++top]=lst[i];
}
}
double A(double x){return x<=-pi/?x+*pi:x;}
void insert(Point p){
vec[++tot].push_back(p),size[tot]=,lst[num=]=p;
while(tot>&&size[tot]==size[tot-]){
for(int i=;i<vec[tot-].size();i++)lst[++num]=vec[tot-][i];
size[tot-]+=size[tot],size[tot]=,vec[tot].clear(),ang[tot].clear(),tot--;
}
Tubao(),vec[tot].clear(),ang[tot].clear();
if(top>){
for(int i=;i<top;i++)vec[tot].push_back(q[i]),ang[tot].push_back(A(atan2(q[i+].y-q[i].y,q[i+].x-q[i].x)));
vec[tot].push_back(q[top]),ang[tot].push_back(A(atan2(q[].y-q[top].y,q[].x-q[top].x)));
}
else vec[tot].push_back(q[]);
}
bool query(){
double angle;
angle=jy.y>?A(atan2(-jy.x,jy.y)):A(atan2(jy.x,-jy.y));
for(int i=;i<=tot;i++){
op=vec[i].size()==?:lower_bound(ang[i].begin(),ang[i].end(),angle)-ang[i].begin();
if(*jy.x*vec[i][op].x+*jy.y*vec[i][op].y-jy.x*jy.x-jy.y*jy.y<eps)return ;
}return ;
}
int main(){
scanf("%d",&n);
for(int i=;i<=n;i++){
scanf("%d%lf%lf",&op,&jy.x,&jy.y),jy.x+=rec,jy.y+=rec;
if(op==)flg=,insert(jy);
else flg&&query()?(puts("Yes"),rec++):puts("No");
}
}
BZOJ 4140 凸包+二进制分组的更多相关文章
- [BZOJ 2989]数列(二进制分组+主席树)
[BZOJ 2989]数列(二进制分组+主席树) 题面 给定一个长度为n的正整数数列a[i]. 定义2个位置的graze值为两者位置差与数值差的和,即graze(x,y)=|x-y|+|a[x]-a[ ...
- bzoj 4398 福慧双修——二进制分组
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4398 如果枚举1号点走哪些点出去,就从那些点出发跑多源最短路即可.最短路不会重复经过一条边. ...
- bzoj 4398 福慧双修 —— 二进制分组+多起点最短路
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4398 按二进制每一位是 0/1 把 1 号点的儿子分成两组,分别作为起点和终点跑多起点最短路 ...
- 题解 bzoj 4398福慧双修(二进制分组)
二进制分组,算个小技巧 bzoj 4398福慧双修 给一张图,同一条边不同方向权值不同,一条边只能走一次,求从1号点出发再回到1号点的最短路 一开始没注意一条边只能走一次这个限制,打了个从一号点相邻节 ...
- bzoj2961 共点圆 bzoj 4140
题解: 比较水的一道题 首先我们化简一下式子发现是维护xxo+yyo的最值 显然是用凸包来做 我们可以直接用支持插入删除的凸包 也是nlogn的 因为没有强制在线,我们也可以cdq,考虑前面一半对答案 ...
- 【BZOJ3821/UOJ46】玄学(二进制分组,线段树)
[BZOJ3821/UOJ46]玄学(二进制分组,线段树) 题面 BZOJ UOJ 题解 呜,很好的题目啊QwQ. 离线做法大概可以线段树分治,或者直接点记录左右两次操作时的结果,两个除一下就可以直接 ...
- 【BZOJ4140】共点圆加强版(二进制分组)
[BZOJ4140]共点圆加强版(二进制分组) 题面 BZOJ 题解 我卡精度卡了一天.... 之前不强制在线的做法是\(CDQ\)分治,维护一个凸壳就好了. 现在改成二进制分组,每次重建凸壳就好了. ...
- 【BZOJ2989】数列(二进制分组,主席树)
[BZOJ2989]数列(二进制分组,主席树) 题面 BZOJ 权限题啊... Description 给定一个长度为n的正整数数列a[i]. 定义2个位置的graze值为两者位置差与数值差的和,即g ...
- 【Codeforces710F】String Set Queries (强制在线)AC自动机 + 二进制分组
F. String Set Queries time limit per test:3 seconds memory limit per test:768 megabytes input:standa ...
随机推荐
- buf.writeUIntBE()函数详解
buf.writeUIntBE(value, offset, byteLength[, noAssert]) buf.writeUIntLE(value, offset, byteLength[, n ...
- concepts in Turbulent Flow
Table of Contents 1. Concepts/Glossary 1.1. Turbulent eddy viscosity ,μt 1.2. Turbulent kinetic ener ...
- 洛谷 2921 [USACO08DEC]在农场万圣节Trick or Treat on the Farm
[题解] 就是基环外向树森林找环,然后从环向外统计size就可以了. #include<cstdio> #include<cstring> #include<algori ...
- 日期工具类 DateTools
为了跟其他日期工具类进行区分起名字DateTools public class DateTools { /** The DAT e_ forma t1. */ public static String ...
- Codeforces Round #246 (Div. 2) D. Prefixes and Suffixes
D. Prefixes and Suffixes You have a string s = s ...
- 所有在Linux系统下 arp -d $ip 命令只能清除一个IP地址的对应MAC地址缓存,可以使用组合命令操作。
https://blog.csdn.net/u011641885/article/details/48175239 https://blog.csdn.net/zj0910/article/detai ...
- PostGIS学习相关术语
POI 兴趣点(英语:point of interest,通常缩写成POI)乃是电子地图上的某个地标.景点,用以标示出该地所代表的政府部门.各行各业之商业机构(加油站.百货公司.超市.餐厅.酒店.便利 ...
- Pivotal-tc-Server与Tomcat区别
Pivotal-tc-Server之前叫做SpringSource tc Server,包含三个版本分别是:Spring版.标准版和开发版,但其中只有开发版是免费的.比如在STS中包含的版本就是开发板 ...
- php 类型转换
PHP数据类型转换 PHP的数据类型转换属于强制转换,允许转换的PHP数据类型有: •(int).(integer):转换成整形 •(float).(double).(real):转换成浮点型 •(s ...
- 【转】keyCode对照表及JS监听组合按键
原文: http://blog.csdn.net/qq_21386275/article/details/67640576 有一些需求,html 页面上的input 框只允许输入数字, 只允许输入小 ...