题意:两种操作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. Windows进程的内核对象句柄表

    当一个进程被初始化时,系统要为它分配一个句柄表.该句柄表只用于内核对象 ,不用于用户对象或GDI对象. 创建内核对象 当进程初次被初始化时,它的句柄表是空的.然后,当进程中的线程调用创建内核对象的函数 ...

  2. P4213 【模板】杜教筛(Sum)(杜教筛)

    根据狄利克雷卷积的性质,可以在低于线性时间复杂度的情况下,求积性函数前缀和 公式 \[ 求\sum_{i=1}^{n}\mu(i) \] 因为\(\mu*I=\epsilon\) 所以设\(h=\mu ...

  3. 3、iptables扩展及使用

    iptables/netfilter netfilter: kernel framework,位于内核中的协议框架 iptables  是规则管理命令行工具 四表:filter, nat, mangl ...

  4. 【转】Windows Live Writer 代码插件改造

    源码和插件都在后面,如果不想看我神神叨叨的可以直接到文章后面下载 一 .找插件 在使用Windows Live Writer 经常要用到插入代码的功能,根据博客园中教程,分别使用了: WindowsL ...

  5. 基于 Python 和 Pandas 的数据分析(4) --- 建立数据集

    这一节我想对使用 Python 和 Pandas 的数据分析做一些扩展. 假设我们是亿万富翁, 我们会想要多元化地进行投资, 比如股票, 分红, 金融市场等, 那么现在我们要聚焦房地产市场, 做一些这 ...

  6. Codeforces 765 E. Tree Folding

    题目链接:http://codeforces.com/problemset/problem/765/E $DFS子$树进行$DP$ 大概分以下几种情况: 1.为叶子,直接返回. 2.长度不同的路径长度 ...

  7. NoSQL(not only struts query language)的简单介绍

    为什么需要NoSQL? 互联网自扩大规模来一直面临3个问题 1.High performance高并发 一个网站开发实时生成动态页面可能会存在高并发请求的需求,硬盘IO已经无法接受 2.Huge St ...

  8. C/C++.全文件名全路径名分割拆分分解

    1._splitpath ZC:windows api的话 可以使用 PathFindFileNameA.PathFindExtensionA.PathFileExistsA等一系列函数 2.测试代码 ...

  9. 力扣(LeetCode)191. 位1的个数

    编写一个函数,输入是一个无符号整数,返回其二进制表达式中数字位数为 '1' 的个数(也被称为汉明重量). 示例 1: 输入:00000000000000000000000000001011 输出:3 ...

  10. mint19 源码安装python3.7

    基于Ubuntu 18.04  自带了3.6,可惜 3.7秒出. 一个原则是: 自带的3.6不要动 防止用apt install python3-XXX时版本不对. 理由: 自带的2.7和3.6都是让 ...