• Codeforces Beta Round #64D


    题意:两种操作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;
    }
    /********************
    
    ********************/
    
  • 相关阅读:
    无题
    Tomcat如何配置环境变量
    linux 下 jdk+tomcat+mysql 的 jsp 环境搭建
    when you're gone
    sublime text3插件篇
    java如何从cmd运行并使用text文件作为输入源的总结
    在发送intent启动activity之前判断是否有activity接收
    contentvalue的探究(结构,用途)
    JAVA input/output 流层次关系图
    activity状态保存的bundl对象存放位置的思考
  • 原文地址:https://www.cnblogs.com/acjiumeng/p/10658102.html
Copyright © 2020-2023  润新知