题意:两种操作1.加点2.查询点是否在之前给定点的凸包内

题解:set维护动态凸包,分别维护上下凸壳,对y取反就行,判断点是否在凸壳内,把点加进去看要不要删除就好了

//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
//#pragma GCC optimize(4)
//#pragma GCC optimize("unroll-loops")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define fi first
#define se second
#define db double
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define ll long long
#define vi vector<int>
#define mod 1000000007
#define ld long double
//#define C 0.5772156649
//#define ls l,m,rt<<1
//#define rs m+1,r,rt<<1|1
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define ull unsigned long long
//#define base 1000000000000000000
#define fin freopen("a.txt","r",stdin)
#define fout freopen("a.txt","w",stdout)
#define fio ios::sync_with_stdio(false);cin.tie(0)
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline void sub(ll &a,ll b){a-=b;if(a<0)a+=mod;}
inline void add(ll &a,ll b){a+=b;if(a>=mod)a-=mod;}
template<typename T>inline T const& MAX(T const &a,T const &b){return a>b?a:b;}
template<typename T>inline T const& MIN(T const &a,T const &b){return a<b?a:b;}
inline ll qp(ll a,ll b){ll ans=1;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod,b>>=1;}return ans;}
inline ll qp(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=ans*a%c;a=a*a%c,b>>=1;}return ans;} using namespace std; const ull ba=233;
const db eps=1e-8;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int N=200000+10,maxn=1000000+10,inf=0x3f3f3f3f; struct node{
ll x,y;
node(){}
node(ll _x,ll _y){x=_x,y=_y;}
node operator -(const node&rhs)const{
return node(x-rhs.x,y-rhs.y);
}
bool operator <(const node&rhs)const{
return x<rhs.x||(x==rhs.x&&y<rhs.y);
}
};
struct hull:set<node>{
bool bad(iterator it)
{
if(it==begin()||next(it)==end())return 0;
return (it->y-prev(it)->y)*(next(it)->x-it->x)<=(next(it)->y-it->y)*(it->x-prev(it)->x);
}
void update(node x)
{
if(find(x)!=end())return ;
iterator it=insert(x).fi;
if(bad(it)){erase(it);return ;}
while(it!=begin()&&bad(prev(it)))
{
// ans-=dis(*it,*prev(it));
erase(prev(it));
}
while(next(it)!=end()&&bad(next(it)))
{
// ans-=dis(*it,*next(it));
erase(next(it));
}
}
bool check(node x)
{
if(find(x)!=end())return 1;
iterator it = insert(x).fi;bool ok=bad(it);erase(x);
return ok;
}
}h,h1;
int main()
{
int n;scanf("%d",&n);
for(int i=1;i<=n;i++)
{
node a;int op;
scanf("%d%lld%lld",&op,&a.x,&a.y);
if(op==1)h.update(a),a.y=-a.y,h1.update(a);
else
{
bool ok=h.check(a);a.y=-a.y;
ok&=h1.check(a);
puts(ok?"YES":"NO");
}
}
return 0;
}
/******************** ********************/

Codeforces Beta Round #64D - Professor's task的更多相关文章

  1. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  2. Codeforces Beta Round #62 题解【ABCD】

    Codeforces Beta Round #62 A Irrational problem 题意 f(x) = x mod p1 mod p2 mod p3 mod p4 问你[a,b]中有多少个数 ...

  3. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  4. Codeforces Beta Round #13 C. Sequence (DP)

    题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考 ...

  5. Codeforces Beta Round #79 (Div. 2 Only)

    Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...

  6. Codeforces Beta Round #77 (Div. 2 Only)

    Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...

  7. Codeforces Beta Round #76 (Div. 2 Only)

    Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...

  8. Codeforces Beta Round #75 (Div. 2 Only)

    Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...

  9. Codeforces Beta Round #74 (Div. 2 Only)

    Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...

随机推荐

  1. p2042 维修数列(SPLAY)

    终于yy过去了 撒花 调了一天半,出了无数锅 以下是出锅列表 rotate的时候要判断父亲节点的父亲节点是否存在 rotate的时候记得修改节点的父亲信息 pushdown的时候注意特判有无左右子树 ...

  2. Twitter开发2

    There are different API families The standard (free) Twitter APIs consist of REST APIs and Streaming ...

  3. HBase与列存储

    传统的行存储和(HBase)列存储的区别 1.为什么要按列存储 列式存储(Columnar or column-based)是相对于传统关系型数据库的行式存储(Row-basedstorage)来说的 ...

  4. Transaction2

    5. 事务状态 TransactionInformation 上面讲解过事务分为本地事务与分布式事务,而Transaction类的TransactionInformation是事务状态的记录,它可以跟 ...

  5. Node.js代码模块化

    js语言发展到现在逐渐的像后端语言来,学习了一些后端语言的特性,这里主要讲述的是js语言的模块化管理 首先新建一个js文件 'use strict'; var s = 'Hello'; functio ...

  6. 【BZOJ】3143: [Hnoi2013]游走

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=3143 显然如果一条边期望被走过的次数越多,我们就应该给它的编号越小. 所以问题变为如何求每 ...

  7. 测试服务器上多个tomcat配置Nginx访问

    user nginx; worker_processes 4; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; wor ...

  8. javaSE习题 第二章 基本数据类型和数组

    问答: 1.什么叫标识符,标识符的规则是什么? 用来标志类名,变量名,方法名,类型名,数组名,文件名的有效字符序列称为标识符. 规则:1.由字母,数字,下划线,美元组成.2.标识符第一个字符不能是数字 ...

  9. java 常用异常及作用

    先看看图, Exception就明白了 关于异常 大体分为 不可查异常 可查异常 runtimeException三类~异常都继承throwable这个类~ 下面有error和Exception两大类 ...

  10. Android自定义权限

    一.自定义权限 自定义权限,一般是考虑到应用共享组件时的安全问题.我们知道在四大组件 AndroidManifest 中注册的时候,添加 exported = "true" 这一属 ...