Codeforces Beta Round #64D - Professor's task
题意:两种操作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的更多相关文章
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- 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]中有多少个数 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #13 C. Sequence (DP)
题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
- Codeforces Beta Round #77 (Div. 2 Only)
Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...
- Codeforces Beta Round #76 (Div. 2 Only)
Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...
- Codeforces Beta Round #75 (Div. 2 Only)
Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...
- Codeforces Beta Round #74 (Div. 2 Only)
Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...
随机推荐
- fastqc
fastqc用于查看测序数据的质量. 1.下载: http://www.bioinformatics.babraham.ac.uk/projects/download.html#fastqc wget ...
- Paper Reading: Perceptual Generative Adversarial Networks for Small Object Detection
Perceptual Generative Adversarial Networks for Small Object Detection 2017-07-11 19:47:46 CVPR 20 ...
- C++笔记(2017/2/9)
this指针 this指针作用就是指向成员函数所作用的对象. 非静态成员函数中可以直接使用this来代表指向该函数作用的对象的指针. 静态成员函数中不能使用this指针. 静态成员 static 定义 ...
- Java常见异常:Exception in thread "main" java.lang.NoClassDefFoundError
在某一路径下执行编译好的class文件出错. 异常如下: E:\liwy>java Test98 Exception in thread "main" java.lang.N ...
- 简单Promise回顾
1:传统的CallBack回调函数let ajax=function(callback){ //dosomething this.setTimeout(()=>{ callback&&a ...
- codeforces 768D Jon and Orbs
题目链接:http://codeforces.com/problemset/problem/768/D 令$f[i][j]$表示当前产生过了$i$个球,产生过了$j$个不同的球的概率. ${Ans_i ...
- JaveWeb 公司项目(3)----- 通过Thrift端口获取数据库数据
前面两篇博客的内容主要是界面搭建的过程,随着界面搭建工作的完成,网页端需要加入数据,原先的B/S架构中C#通过Thrift接口获取数据,所以在网页端也沿用这个设计 首先,新建一个Maven下的Web项 ...
- git创建、删除分支
//创建分支 git branch branchname //创建并切换到新分支 git checkout -b branchname //远程分支 git push origin branchnam ...
- 解决VS2017引用报错问题
1.打开VS2017下的Developer Command Prompt for VS 2017 2.然后在CMD窗口输入 CD CD C:\Program Files\Microsoft Visua ...
- 重装win7系统并激活
备份 大白菜制作启动盘 下载大白菜软件UEFI版(新电脑使用uefi版本,装机版支持的主板多) 选择默认安装 选择默认模式开始制作 下载iso镜像文件,复制到u盘(手动复制) 设置bios ...