//Place your snippets for cpp here. Each snippet is defined under a snippet name and has a prefix, body and 
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the 
// same ids are connected.
// prefix 的格式要求是 acm-[一级标题编号].[二级标题编号][该代码片段的英文简称]
// description 的格式要求是 "插入 [该代码片段的中文名]"

{
    "动态凸包": {
        "prefix": "acm-8.3Professor's task",
        "body": [
            "#include<algorithm>",
            "#include<cstdio>",
            "#include<set>",
            "#define LL long long",
            "#define Vector Point",
            "#define Re register int",
            "#define IT set<Point>::iterator",
            "using namespace std;",
            "const int inf=2e9;",
            "inline void in(Re &x){",
            "    int f=0;x=0;char c=getchar();",
            "    while(c<'0'||c>'9')f|=c=='-',c=getchar();",
            "    while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();",
            "    x=f?-x:x;",
            "}",
            "struct Point{",
            "    LL x,y;Point(LL X=0,LL Y=0){x=X,y=Y;}",
            "    inline void In(){Re X,Y;in(X),in(Y),x=X,y=Y;}",
            "    inline bool operator<(const Point &O)const{return x!=O.x?x<O.x:y<O.y;}",
            "}P;",
            "inline LL Cro(Vector a,Vector b){return a.x*b.y-a.y*b.x;}",
            "inline Vector operator-(Vector a,Vector b){return Vector(a.x-b.x,a.y-b.y);}",
            "struct ConvexHull{",
            "\tint op;set<Point>s;",
            "\tinline int PIP(Point P){",
            "\t\tIT it=s.lower_bound(Point(P.x,-inf));",
            "\t\tif(it==s.end())return 0;",
            "\t\tif(it->x==P.x)return (P.y-it->y)*op<=0;",
            "\t\tif(it==s.begin())return 0;",
            "\t\tIT j=it,k=it;--j;return Cro(P-*j,*k-*j)*op>=0;",
            "\t}",
            "\tinline int judge(IT it){",
            "\t\tIT j=it,k=it;",
            "\t\tif(j==s.begin())return 0;--j;",
            "\t\tif(++k==s.end())return 0;",
            "\t\treturn Cro(*it-*j,*k-*j)*op>=0;",
            "\t}",
            "\tinline void insert(Point P){",
            "\t\tif(PIP(P))return;",
            "\t\tIT tmp=s.lower_bound(Point(P.x,-inf));if(tmp!=s.end()&&tmp->x==P.x)s.erase(tmp);",
            "\t\ts.insert(P);IT it=s.find(P),p=it;",
            "\t\tif(p!=s.begin()){--p;while(judge(p)){IT tmp=p--;s.erase(tmp);}}",
            "\t\tif((p=++it)!=s.end())while(judge(p)){IT tmp=p++;s.erase(tmp);}",
            "\t}",
            "}up,down;",
            "int x,y,T,op;",
            "int main(){",
            "//\tfreopen(\"123.txt\",\"r\",stdin);",
            "\tin(T),up.op=1,down.op=-1;",
            "\twhile(T--){",
            "\t\tin(op),P.In();",
            "\t\tif(op<2)up.insert(P),down.insert(P);",
            "\t\telse puts((up.PIP(P)&&down.PIP(P))?\"YES\":\"NO\");",
            "\t}",
            "}",
            ""
        ],
        "description": "插入 动态凸包"
    }
}