BZOJ 4140: 共点圆加强版 [二进制分组]
来源:互联网 发布:手机淘宝如何上传视频 编辑:程序博客网 时间:2024/05/22 04:28
Description
要求支持两个操作:
0 x y 加入一个圆心为(x,y) 的过原点的圆。1 x y 询问点(x,y) 是否在所有圆内部。
强制在线。
Solution
二进制分组都不会啊
一个点
就相当于是所有点都要在这条直线的上方。
在凸包上用这条直线逼近,直到有焦点,再判断一下截距的大小就好了。
实现的话,就是二分凸包上的斜率。
这道题要求强制在线。
二进制分组!
#include <bits/stdc++.h>using namespace std;const int N = 510010;const int M = 30;const double eps = 1e-8;struct Point { double x, y; Point (double _x = 0, double _y = 0):x(_x), y(_y) {} inline friend Point operator -(const Point &a, const Point &b) { return Point(a.x - b.x, a.y - b.y); } inline friend double operator *(const Point &a, const Point &b) { return a.x * b.y - b.x * a.y; } inline friend double operator /(const Point &a, const Point &b) { return (a.y - b.y) / (a.x - b.x); } inline friend bool operator <(const Point &a, const Point &b) { return a.x == b.x ? a.y < b.y : a.x < b.x; }};Point In;int n, opt, lim, cnt, online;double x, y;Point sta[N];struct Group { vector<Point> a, b; int lim, size, usd; inline void ConvexHull(void) { b.clear(); size = 0; usd = 1; sort(a.begin(), a.end()); sta[++size] = a[0]; for (int i = 1; i < lim; i++) { while (size > 1 && (sta[size] - sta[size - 1]) * (a[i] - sta[size]) - eps < 0) --size; sta[++size] = a[i]; } for (int i = 1; i <= size; i++) b.push_back(sta[i]); } inline bool Query(double x0, double y0, double k) { int L = 1, R = size - 1, Mid, Pos = 0; while (L <= R) { Mid = (L + R) >> 1; if (k > b[Mid] / b[Mid - 1]) { L = Mid + 1; Pos = Mid; } else R = Mid - 1; } return x0 * x0 + y0 * y0 - 2.0 * x0 * b[Pos].x - 2.0 * y0 * b[Pos].y - eps < 0; }};Group B[M];inline void MakeGroup(Point &x, int pos) { int cnt = 0; B[pos].a.clear(); B[pos].a.push_back(x); for (int i = 1; i < pos; i++) { B[i].usd = 0; for (int j = 0; j < B[i].lim; j++) B[pos].a.push_back(B[i].a[j]); } B[pos].usd = 1; B[pos].ConvexHull();}inline void Insert(Point &x) { for (int i = 1; i <= lim; i++) if (!B[i].usd) return MakeGroup(x, i);}inline bool Query(double x0, double y0) { double k = -x0 / y0; bool flag = (In.y != 0); for (int i = 1; i <= lim; i++) if (B[i].usd) flag &= B[i].Query(x0, y0, k); return flag;}int main(void) { freopen("1.in", "r", stdin); scanf("%d", &n); lim = 25; for (int i = 1; i <= lim; i++) B[i].lim = 1 << (i - 1); for (int i = 1; i <= n; i++) { scanf("%d%lf%lf", &opt, &x, &y); x += online; y += online; if (opt) { if (Query(x, y)) { puts("Yes"); online++; } else puts("No"); } else { Insert(In = Point(x, y)); } } return 0;}
阅读全文
2 0
- [二进制分组] BZOJ 4140 共点圆加强版
- BZOJ 4140: 共点圆加强版 [二进制分组]
- [二进制分组] BZOJ4140. 共点圆加强版
- 【BZOJ 4253】密码箱加强版
- bzoj-2594 水管局长数据加强版
- BZOJ 3514 Codechef MARCH14 GERALD07加强版
- BZOJ 4543: [POI2014]Hotel加强版 长链剖分
- BZOJ 3265 志愿者招募(BZOJ 1061)加强版 && BZOJ 3112 [Zjoi2013]防守战线 单纯形
- HDU 6166 二进制分组
- 【BZOJ】【P3265】【志愿者招募加强版】【题解】【单纯形法】
- BZOJ 3514 Codechef MARCH14 GERALD07加强版 LCT+主席树
- 【BZOJ】【P2594】【Wc2006】【水管局长数据加强版】【题解】【LCT】
- 【BZOJ 2594】 [Wc2006]水管局长数据加强版
- BZOJ 3265 志愿者招募加强版 单纯形
- 【LCT】【bzoj 3514】: Codechef MARCH14 GERALD07加强版
- BZOJ 2594 [Wc2006]水管局长数据加强版 LCT
- BZOJ 3514 Codechef MARCH14 GERALD07加强版 LCT+主席树
- 【 bzoj 3514 】Codechef MARCH14 GERALD07加强版 - LCT
- [转]moveToThread
- Java学习中,对登陆的总结。
- (转载)maven搭建ssm分模块框架 (myeclipse版) (二) 较详细版
- JNI开发
- 通过acpi_device_hid 得到device的HID
- BZOJ 4140: 共点圆加强版 [二进制分组]
- Java:接口与抽象类
- Mathematica SPWM
- Qt namespace Ui 使用
- 注解和反射结合使用例子
- java.lang.Exception: No runnable methods
- makefile后缀规则
- transform属性不能同时写scale和rotate,怎么办??
- 前端html+css(1)