题意:两种操作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. 集合00_Java集合框架

    集合类概述 1.继承树 2.集合和数组 区别如下: 数组可以存储基本数据类型,也可以存储引用类型:而集合只能存储引用类型(比如存储int,它会自动装箱成Integer) 数组长度固定,集合长度可变 3 ...

  2. Windows常用的CMD命令

    mspaint 打开画图 write 打开写字板 explorer 打开文件资源管理器 notepad 打开记事本 devmgmt.msc 打开设备管理器 regedit 打开注册表编辑器 Mscon ...

  3. Java基础【基本数据类型包装类、int与String 之间的相互转换】

    为什么会有基本类型包装类? 将基本类型数据类型封装成对象,这样的好处可以在对象中定义更多方法操作该数据. 包装类常用的操作就是用于基本数据类型与字符串之间的转换 问题:int a=100; 为什么不能 ...

  4. 【译】第9节---EF Code First中数据注解

    原文:http://www.entityframeworktutorial.net/code-first/dataannotation-in-code-first.aspx EF Code-First ...

  5. python基础-PyYaml操作yaml文件

    yaml语法 格式 它的基本语法规则如下 大小写敏感 使用缩进表示层级关系 缩进时不允许使用Tab键,只允许使用空格. 缩进的空格数目不重要,只要相同层级的元素左侧对齐即可 YAML 支持的数据结构有 ...

  6. android studio 的基本使用和建立一个小项目

    https://github.com/allenxieyusheng/Android-Studio

  7. MySQL数据分组Group By 和 Having

    现有以下的学生信息表: 若果现在想计算每个班的平均年龄,使用where的操作如下: SELECT Cno AS 班级, AVG(Sage) AS 平均年龄 FROM stu ; 这样的话,有多少个班就 ...

  8. ssh连接docker镜像ubuntu与debian

    用密码登录root docker官网给的sshdemo是ubuntu的,https://docs.docker.com/engine/examples/running_ssh_service/   亲 ...

  9. linux基础01-bash特性

    (1) ls -l:长格式文件类型: -:普通文件 (f) d: 目录文件 b: 块设备文件 (block) c: 字符设备文件 (character) l: 符号链接文件(symbolic link ...

  10. python+selenium基础之XPATH定位(第一篇)

    世界上最远的距离大概就是明明看到一个页面元素矗在那里,但是我却定位不到!! selenium定位元素的方法有很多种,像是通过id.name.class_name.tag_name.link_text等 ...