QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#197905#6378. LaLa and Monster Hunting (Part 1)Zhou_JKAC ✓582ms58212kbC++2329.3kb2023-10-02 21:32:142023-10-02 21:32:14

Judging History

你现在查看的是最新测评结果

  • [2023-10-02 21:32:14]
  • 评测
  • 测评结果:AC
  • 用时:582ms
  • 内存:58212kb
  • [2023-10-02 21:32:14]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cassert>
#include<chrono>
#include<random>
#include<vector>
#include<functional>
#include<iomanip>
#include<algorithm>
using namespace std;
namespace Geometry
{
    const double eps=1e-12;
    const double PI=acos(-1);
    const double INF=1e18;
    bool equal(double a,double b)
    {
        return abs(a-b)<eps;
    }
    bool less(double a,double b)
    {
        return b-a>=eps;
    }
    bool greater(double a,double b)
    {
        return a-b>=eps;
    }
    bool less_equal(double a,double b)
    {
        return b-a>-eps;
    }
    bool greater_equal(double a,double b)
    {
        return a-b>-eps;
    }
    class Point
    {
    public:
        double x,y;
        Point(){x=0,y=0;}
        Point(const double &_x,const double &_y):x(_x),y(_y) {}
        friend Point operator * (const Point &a,const double &b)
        {
            return Point(a.x*b,a.y*b);
        }
        friend Point operator * (const double &a,const Point &b)
        {
            return Point(a*b.x,a*b.y);
        }
        friend Point operator / (const Point &a,const double &b)
        {
            return Point(a.x/b,a.y/b);
        }
        friend Point operator + (const Point &a,const Point &b)
        {
            return Point(a.x+b.x,a.y+b.y);
        }
        Point operator += (const Point &b)
        {
            x+=b.x,y+=b.y;
            return *this;
        }
        friend Point operator - (const Point &a,const Point &b)
        {
            return Point(a.x-b.x,a.y-b.y);
        }
        Point operator -= (const Point &b)
        {
            x-=b.x,y-=b.y;
            return *this;
        }
        friend double cross(const Point &a,const Point &b)
        {
            return a.x*b.y-a.y*b.x;
        }
        friend double dot(const Point &a,const Point &b)
        {
            return a.x*b.x+a.y*b.y;
        }
        friend bool operator == (const Point &a,const Point &b)
        {
            return equal(a.x,b.x)&&equal(a.y,b.y);
        }
        friend bool operator != (const Point &a,const Point &b)
        {
            return (!equal(a.x,b.x))||(!equal(a.y,b.y));
        }
        friend bool operator < (const Point &a,const Point &b)
        {
            if(equal(a.x,b.x)) return less(a.y,b.y);
            else return less(a.x,b.x);
        }
        friend bool operator > (const Point &a,const Point &b)
        {
            if(equal(a.x,b.x)) return greater(a.y,b.y);
            else return greater(a.x,b.x);
        }
        friend bool operator <= (const Point &a,const Point &b)
        {
            if(equal(a.x,b.x)) return less_equal(a.y,b.y);
            else return less_equal(a.x,b.x);
        }
        friend bool operator >= (const Point &a,const Point &b)
        {
            if(equal(a.x,b.x)) return greater_equal(a.y,b.y);
            else return greater_equal(a.x,b.x);
        }
        Point operator - ()const
        {
            return Point(-x,-y);
        }
        double length()const
        {
            return sqrt(x*x+y*y);
        }
        Point unit()const
        {
            return *this/length();
        }
        double angle()const
        {
            return atan2(y,x);
        }
        int quadrant()const
        {
            if(x>0&&y>=0) return 1;
            else if(x<=0&&y>0) return 2;
            else if(x<0&&y<=0) return 3;
            else if(x>=0&&y<0) return 4;
            else return 0;
        }
        friend double angle(const Point &a,const Point &b)
        {
            return atan2(cross(a,b),dot(a,b));
        }
        Point rotate(const double &theta)const
        {
            return Point(x*cos(theta)-y*sin(theta),x*sin(theta)+y*cos(theta));
        }
        friend istream &operator>>(istream &in,Point &obj)
        {
            in>>obj.x>>obj.y;
            return in;
        }
        friend ostream &operator<<(ostream &out,const Point &obj)
        {
            out<<obj.x<<" "<<obj.y;
            return out;
        }
    };
    double distance(const Point &a,const Point &b)
    {
        return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
    }
    enum Direction
    {
        COUNTER_CLOCKWISE,
        CLOCKWISE,
        ONLINE_BACK,
        ONLINE_FRONT,
        ON_SEGMENT
    };
    istream& operator>>(istream& in,Direction& direction)
    {
        string value;
        in>>value;
        if(value=="COUNTER_CLOCKWISE") direction=COUNTER_CLOCKWISE;
        else if(value=="CLOCKWISE") direction=CLOCKWISE;
        else if(value=="ONLINE_BACK") direction=ONLINE_BACK;
        else if(value=="ONLINE_FRONT") direction=ONLINE_FRONT;
        else if(value=="ON_SEGMENT") direction=ON_SEGMENT;
        else in.setstate(ios::failbit);
        return in;
    }
    ostream& operator<<(ostream& out,const Direction& direction)
    {
        if(direction==COUNTER_CLOCKWISE) out<<"COUNTER_CLOCKWISE";
        else if(direction==CLOCKWISE) out<<"CLOCKWISE";
        else if(direction==ONLINE_BACK) out<<"ONLINE_BACK";
        else if(direction==ONLINE_FRONT) out<<"ONLINE_FRONT";
        else if(direction==ON_SEGMENT) out<<"ON_SEGMENT";
        return out;
    }
    class Line
    {
    public:
        Point a,b;
        Line(){}
        Line(const Point &_a,const Point &_b):a(_a),b(_b){}
        Point projection(const Point &p)const
        {
            return a+(b-a).unit()*(dot(p-a,b-a)/(b-a).length());
        }
        Point reflection(const Point &p)const
        {
            return projection(p)*2-p;
        }
        Direction direction(const Point &p)const
        {
            double t=cross(b-a,p-a);
            if(greater(t,0)) return COUNTER_CLOCKWISE;
            if(less(t,0)) return CLOCKWISE;
            double l1=dot(p-a,b-a);
            if(less(l1,0)) return ONLINE_BACK;
            double l2=dot(b-a,b-a);
            if(l1>l2) return ONLINE_FRONT;
            else return ON_SEGMENT;
        }
        double distance(const Point &p)const
        {
            Point u=projection(p);
            if(direction(u)==ON_SEGMENT) return Geometry::distance(u,p);
            else return min(Geometry::distance(a,p),Geometry::distance(b,p));
        }
        friend istream &operator>>(istream &in,Line &obj)
        {
            in>>obj.a>>obj.b;
            return in;
        }
        friend ostream &operator<<(ostream &out,const Line &obj)
        {
            out<<obj.a<<" "<<obj.b;
            return out;
        }
    };
    bool parallel(const Line &x,const Line &y)
    {
        return equal(cross(x.b-x.a,y.b-y.a),0);
    }
    bool orthogonal(const Line &x,const Line &y)
    {
        return equal(dot(x.b-x.a,y.b-y.a),0);
    }
    vector<Point> cross_point(const Line &x,const Line &y)
    {
        if(parallel(x,y)) return {};
        Point u=x.a-y.a,v=x.b-x.a,w=y.b-y.a;
        double t=cross(w,u)/cross(v,w);
        return {x.a+t*v};
    }
    int sign(double x)
    {
        return greater(x,0)-less(x,0);
    }
    bool intersection(const Line &x,const Line &y)
    {
        if(x.direction(y.a)==ON_SEGMENT||x.direction(y.b)==ON_SEGMENT||y.direction(x.a)==ON_SEGMENT||y.direction(x.b)==ON_SEGMENT) return true;
        return sign(cross(x.b-x.a,y.a-x.a))*sign(cross(x.b-x.a,y.b-x.a))<0&&sign(cross(y.b-y.a,x.a-y.a))*sign(cross(y.b-y.a,x.b-y.a))<0;
    }
    double distance(const Line &x,const Line &y)
    {
        if(intersection(x,y)) return 0;
        else return min({x.distance(y.a),x.distance(y.b),y.distance(x.a),y.distance(x.b)});
    }
    const int IN=2,ON=1,OUT=0;
    mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
    class Polygon
    {
    private:
        vector<Point>g;
    public:
        Polygon(){}
        Polygon(const int &n){g.resize(n);}
        Polygon(const vector<Point> &f):g(f){}
        void clear()
        {
            g.clear();
        }
        void resize(int n)
        {
            g.resize(n);
        }
        void push_back(const Point &x)
        {
            return g.push_back(x);
        }
        void push_back(const vector<Point> &x)
        {
            for(const Point &p:x)
                g.push_back(p);
            return;
        }
        void pop_back()
        {
            return g.pop_back();
        }
        Point& front()
        {
            return g.front();
        }
        const Point& front()const
        {
            return g.front();
        }
        Point& back()
        {
            return g.back();
        }
        const Point& back()const
        {
            return g.back();
        }
        size_t size()const
        {
            return g.size();
        }
        Point& operator [](const int &i)
        {
            return g[i];
        }
        const Point& operator [](const int &i)const
        {
            return g[i];
        }
        vector<Point>::iterator begin()
        {
            return g.begin();
        }
        vector<Point>::iterator end()
        {
            return g.end();
        }
        vector<Point>::const_iterator begin()const
        {
            return g.begin();
        }
        vector<Point>::const_iterator end()const
        {
            return g.end();
        }
        vector<Point>::reverse_iterator rbegin()
        {
            return g.rbegin();
        }
        vector<Point>::reverse_iterator rend()
        {
            return g.rend();
        }
        vector<Point>::const_reverse_iterator rbegin()const
        {
            return g.rbegin();
        }
        vector<Point>::const_reverse_iterator rend()const
        {
            return g.rend();
        }
        double area()const
        {
            int n=g.size();
            double res=0;
            for(int i=0;i<n;i++)
                res+=cross(g[i],g[(i+1)%n]);
            res/=2;
            return abs(res);
        }
        double perimeter()const
        {
            int n=g.size();
            double sum=0;
            for(int i=0;i<n;i++)
                sum+=distance(g[i],g[(i+1)%n]);
            return sum;
        }
        bool is_convex()const
        {
            int n=g.size();
            for(int i=0;i<n;i++)
                if(less(cross(g[(i+1)%n]-g[i],g[(i-1+n)%n]-g[i]),0)) return false;
            return true;
        }
        int point_containment(const Point &a)const
        {
            int n=g.size();
            for(int i=0;i<n;i++)
                if(Line(g[i],g[(i+1)%n]).direction(a)==ON_SEGMENT) return ON;
            function<bool(const Line &)> check=[=](const Line &l)
            {
                for(int i=0;i<n;i++)
                    if(parallel(l,Line(g[i],g[(i+1)%n]))) return false;
                for(int i=0;i<n;i++)
                    if(l.direction(g[i])==ON_SEGMENT||l.direction(g[i])==ONLINE_FRONT||l.direction(g[i])==ONLINE_BACK) return false;
                return true;
            };
            Line l=Line(a,Point(rnd(),rnd()));
            while(!check(l))
                l=Line(a,Point(rnd(),rnd()));
            int s=0;
            for(int i=0;i<n;i++)
                if(intersection(l,Line(g[i],g[(i+1)%n]))) s++;
            if(s&1) return IN;
            else return OUT;
        }
        double convex_diamater()const
        {
            int n=g.size();
            double ans=0;
            for(int i=0,j=0;i<n;i++)
            {
                while(less(cross(g[i]-g[j],g[(i+1)%n]-g[j]),cross(g[i]-g[(j+1)%n],g[(i+1)%n]-g[(j+1)%n]))) j=(j+1)%n;
                ans=max(ans,max(distance(g[j],g[i]),distance(g[j],g[(i+1)%n])));
            }
            return ans;
        }
        pair<Polygon,Polygon> convex_cut(const Line &l)const
        {
            Polygon res1,res2;
            int n=g.size();
            for(int i=0;i<(int)g.size();i++)
            {
                Point u=g[i],v=g[(i+1)%n];
                if(greater_equal(cross(l.b-l.a,u-l.a),0))
                {
                    res1.push_back(u);
                    if(less(cross(l.b-l.a,v-l.a),0)) res1.push_back(cross_point(Line(u,v),l));
                }
                else if(greater(cross(l.b-l.a,v-l.a),0)) res1.push_back(cross_point(Line(u,v),l));
            }
            for(int i=0;i<(int)g.size();i++)
            {
                Point u=g[i],v=g[(i+1)%n];
                if(greater_equal(cross(l.a-l.b,u-l.b),0))
                {
                    res2.push_back(u);
                    if(less(cross(l.a-l.b,v-l.b),0)) res2.push_back(cross_point(Line(u,v),l));
                }
                else if(greater(cross(l.a-l.b,v-l.b),0)) res2.push_back(cross_point(Line(u,v),l));
            }
            return make_pair(res1,res2);
        }
        Polygon kernel()const;
    };
    Polygon convex_hull(const vector<Point> &_p)
    {
        vector<Point> p=_p;
        int n=p.size();
        if(n<=2)
        {
            sort(p.begin(),p.end(),[](const Point &a,const Point &b){return a.y==b.y?a.x<b.x:a.y<b.y;});
            Polygon res;
            for(const Point &q:p)
                res.push_back(q);
            return res;
        }
        sort(p.begin(),p.end(),[](const Point &a,const Point &b){return a.x==b.x?a.y<b.y:a.x<b.x;});
        vector<int>stk;
        int top=0;
        for(int i=0;i<n;i++)
        {
            while(top>=2&&less_equal(cross(p[stk[top-1]]-p[stk[top-2]],p[i]-p[stk[top-1]]),0)) stk.pop_back(),top--;
            stk.emplace_back(i),top++;
        }
        int tmp=top;
        for(int i=n-2;i>=0;i--)
        {
            while(top>tmp&&less_equal(cross(p[stk[top-1]]-p[stk[top-2]],p[i]-p[stk[top-1]]),0)) stk.pop_back(),top--;
            stk.emplace_back(i),top++;
        }
        stk.pop_back(),top--;
        vector<Point>hull;
        for(int i=0;i<top;i++)
            hull.emplace_back(p[stk[i]]);
        int t=min_element(hull.begin(),hull.end(),[](const Point &a,const Point &b){return a.y==b.y?a.x<b.x:a.y<b.y;})-hull.begin();
        Polygon res;
        for(int i=t;i<top;i++)
            res.push_back(hull[i]);
        for(int i=0;i<t;i++)
            res.push_back(hull[i]);
        return res;
    }
    Polygon non_strictly_convex_hull(const vector<Point> &_p)
    {
        vector<Point> p=_p;
        int n=p.size();
        if(n<=2)
        {
            sort(p.begin(),p.end(),[](const Point &a,const Point &b){return a.y==b.y?a.x<b.x:a.y<b.y;});
            Polygon res;
            for(const Point &q:p)
                res.push_back(q);
            return res;
        }
        sort(p.begin(),p.end(),[](const Point &a,const Point &b){return a.x==b.x?a.y<b.y:a.x<b.x;});
        vector<int>stk;
        int top=0;
        for(int i=0;i<n;i++)
        {
            while(top>=2&&less(cross(p[stk[top-1]]-p[stk[top-2]],p[i]-p[stk[top-1]]),0)) stk.pop_back(),top--;
            stk.emplace_back(i),top++;
        }
        int tmp=top;
        for(int i=n-2;i>=0;i--)
        {
            while(top>tmp&&less(cross(p[stk[top-1]]-p[stk[top-2]],p[i]-p[stk[top-1]]),0)) stk.pop_back(),top--;
            stk.emplace_back(i),top++;
        }
        stk.pop_back(),top--;
        vector<Point>hull;
        for(int i=0;i<top;i++)
            hull.emplace_back(p[stk[i]]);
        int t=min_element(hull.begin(),hull.end(),[](const Point &a,const Point &b){return a.y==b.y?a.x<b.x:a.y<b.y;})-hull.begin();
        Polygon res;
        for(int i=t;i<top;i++)
            res.push_back(hull[i]);
        for(int i=0;i<t;i++)
            res.push_back(hull[i]);
        return res;
    }
    Polygon minkowski_sum(const vector<Point> &a,const vector<Point> &b)
    {
        assert(a.size()!=0&&b.size()!=0);
        Polygon ca=convex_hull(a),cb=convex_hull(b);
        int na=ca.size(),nb=cb.size();
        vector<Point>la,lb;
        for(int i=0;i<na;i++)
            la.emplace_back(ca[(i+1)%na]-ca[i]);
        for(int i=0;i<nb;i++)
            lb.emplace_back(cb[(i+1)%nb]-cb[i]);
        int pa=0,pb=0;
        vector<Point> l;
        l.emplace_back(ca[0]+cb[0]);
        while(pa<(int)la.size()&&pb<(int)lb.size())
        {
            double val=cross(la[pa],lb[pb]);
            if(greater(val,0)) l.emplace_back(l.back()+la[pa]),pa++;
            else if(less(val,0)) l.emplace_back(l.back()+lb[pb]),pb++;
            else l.emplace_back(l.back()+la[pa]+lb[pb]),pa++,pb++;
        }
        while(pa<(int)la.size())
            l.emplace_back(l.back()+la[pa]),pa++;
        while(pb<(int)lb.size())
            l.emplace_back(l.back()+lb[pb]),pb++;
        Polygon res=convex_hull(l);
        return res;
    }
    Polygon half_plane_intersection(const vector<Line> &l,double x1=-INF,double y1=-INF,double x2=INF,double y2=INF)
    {
        vector<pair<double,Line>>f;
        for(int i=0;i<(int)l.size();i++)
            f.emplace_back((l[i].b-l[i].a).angle(),l[i]);
        f.emplace_back(0,Line(Point(x1,y1),Point(x2,y1)));
        f.emplace_back(PI/2,Line(Point(x2,y1),Point(x2,y2)));
        f.emplace_back(PI,Line(Point(x2,y2),Point(x1,y2)));
        f.emplace_back(-PI/2,Line(Point(x1,y2),Point(x1,y1)));
        int n=f.size();
        sort(f.begin(),f.end(),[](const pair<double,Line> &a,const pair<double,Line> &b){return !equal(a.first,b.first)?a.first<b.first:a.second.direction(b.second.a)==CLOCKWISE;});
        vector<Line>Ql(n);
        vector<Point>Qp(n);
        Polygon res;
        int head=0,tail=-1;
        Ql[++tail]=f[0].second;
        for(int i=1;i<n;i++)
            if(!equal(f[i].first,f[i-1].first))
            {
                while(head<tail&&f[i].second.direction(Qp[tail-1])==CLOCKWISE) tail--;
                while(head<tail&&f[i].second.direction(Qp[head])==CLOCKWISE) head++;
                Ql[++tail]=f[i].second;
                if(head<tail)
                {
                    vector<Point> tmp=cross_point(Ql[tail],Ql[tail-1]);
                    if(!tmp.empty()) Qp[tail-1]=tmp[0];
                    else return res;
                }
            }
        while(head<tail&&Ql[head].direction(Qp[tail-1])==CLOCKWISE) tail--;
        while(head<tail&&Ql[tail].direction(Qp[head])==CLOCKWISE) head++;
        vector<Point> tmp=cross_point(Ql[tail],Ql[head]);
        if(tmp.empty()||tail-head+1<=2) return res;
        for(int i=head;i<tail;i++)
            res.push_back(Qp[i]);
        res.push_back(tmp[0]);
        return res;
    }
    Polygon Polygon::kernel()const
    {
        int n=g.size();
        vector<Line>l;
        for(int i=0;i<n;i++)
            l.emplace_back(Line(g[i],g[(i+1)%n]));
        return half_plane_intersection(l);
    }
    double closest_pair(const vector<Point> &_p)
    {
        vector<Point>p=_p;
        sort(p.begin(),p.end(),[](const Point &a,const Point &b){return a.x<b.x;});
        function<double(const int &,const int &)> solve=[&](const int &l,const int &r)
        {
            if(r-l+1<=1) return INF;
            if(r-l+1<=7)
            {
                double ans=INF;
                sort(p.begin()+l,p.begin()+r+1,[](const Point &a,const Point &b){return a.y<b.y;});
                for(int i=l;i<=r;i++)
                    for(int j=i+1;j<=r;j++)
                        ans=min(ans,distance(p[i],p[j]));
                return ans;
            }
            int mid=(l+r)/2;
            double w=p[mid].x;
            double d=min(solve(l,mid),solve(mid+1,r));
            inplace_merge(p.begin()+l,p.begin()+mid+1,p.begin()+r+1,[](const Point &a,const Point &b){return a.y<b.y;});
            vector<Point>q;
            for(int i=l;i<=r;i++)
                if(abs(w-p[i].x)<=d) q.emplace_back(p[i]);
            for(int i=0,j=0;i<(int)q.size();i++)
            {
                while(j<(int)q.size()&&q[j].y<=q[i].y+d) j++;
                for(int k=i+1;k<j;k++)
                    d=min(d,distance(q[i],q[k]));
            }
            return d;
        };
        return solve(0,p.size()-1);
    }
    class Circle
    {
    public:
        Point o;
        double r;
        Circle(){}
        Circle(const Point &_o,const double &_r):o(_o),r(_r){}
        friend istream &operator>>(istream &in,Circle &obj)
        {
            in>>obj.o>>obj.r;
            return in;
        }
        friend ostream &operator<<(ostream &out,const Circle &obj)
        {
            out<<obj.o<<" "<<obj.r;
            return out;
        }
        friend bool operator==(const Circle &a,const Circle &b)
        {
            return a.o==b.o&&equal(a.r,b.r); 
        }
        friend bool operator!=(const Circle &a,const Circle &b)
        {
            return a.o!=b.o||(!equal(a.r,b.r)); 
        }
        double area()const
        {
            return PI*r*r;
        }
        bool is_tangent(const Line &l)const
        {
            return equal(Geometry::distance(l.projection(o),o),r);
        }
        int point_containment(const Point &p)const
        {
            double d=distance(o,p);
            if(equal(d,r)) return ON;
            else if(less(d,r)) return IN;
            else return OUT;
        }
        vector<Point>cross_point(const Line &l)const
        {
            Point pr=l.projection(o),e=(l.b-l.a).unit();
            double d=distance(pr,o);
            if(greater(d,r)) return {};
            double t=sqrt(r*r-distance(pr,o)*distance(pr,o));
            if(equal(t,0)) return {pr};
            else return {pr-e*t,pr+e*t};
        }
        vector<Point>cross_point(const Circle &c)const
        {
            double d=distance(o,c.o);
            if(less(d,abs(r-c.r))||greater(d,r+c.r)) return {};
            double x=(r*r-c.r*c.r+d*d)/(d*2),h=sqrt(r*r-x*x);
            Point p=o+(c.o-o).unit()*x;
            if(equal(d,abs(r-c.r))||equal(d,r+c.r)) return {p};
            Point v=(c.o-o).unit().rotate(PI/2)*h;
            return {p-v,p+v};
        }
        vector<Point>tangent(const Point &p)const
        {
            double d=distance(o,p);
            if(greater(r,d)) return {};
            if(equal(d,r)) return {p};
            return cross_point(Circle(p,sqrt(d*d-r*r)));
        }
        vector<Line>common_tangent_out(const Circle &c)const
        {
            assert(*this!=c);
            if(equal(r,c.r))
            {
				Point p=(c.o-o).unit().rotate(PI/2)*r;
				return {Line(o-p,c.o-p),Line(o+p,c.o+p)};
            }
            double d=distance(o,c.o);
            if(less(d,abs(r-c.r))) return {};
            if(equal(d,abs(r-c.r)))
            {
                Point p;
                if(r>c.r) p=o+(c.o-o).unit()*r;
                else p=c.o+(o-c.o).unit()*c.r;
                return {Line(p,p)}; 
            }
            Point p((o.x*c.r-c.o.x*r)/(c.r-r),(o.y*c.r-c.o.y*r)/(c.r-r));
            vector<Point>p1=tangent(p),p2=c.tangent(p);
            assert((int)p1.size()==2&&(int)p2.size()==2);
            return {Line(p1[0],p2[0]),Line(p1[1],p2[1])};
        }
        vector<Line>common_tangent_in(const Circle &c)const
        {
            assert(*this!=c);
            double d=distance(o,c.o);
            if(less(d,abs(r+c.r))) return {};
            if(equal(d,abs(r+c.r)))
            {
                Point p=o+(c.o-o).unit()*r;
                return {Line(p,p)}; 
            }
            Point p((o.x*c.r+c.o.x*r)/(r+c.r),(o.y*c.r+c.o.y*r)/(r+c.r));
            vector<Point>p1=tangent(p),p2=c.tangent(p);
            assert((int)p1.size()==2&&(int)p2.size()==2);
            return {Line(p1[0],p2[0]),Line(p1[1],p2[1])};
        }
        vector<Line>common_tangent(const Circle &c)const
        {
            assert(*this!=c);
            vector<Line>f=common_tangent_out(c),g=common_tangent_in(c);
            for(const Line &l:g)
                f.emplace_back(l);
            g.clear();
            sort(f.begin(),f.end(),[](const Line &x,const Line &y){return x.a.x<y.a.x||(x.a.x==x.a.x&&x.a.y<x.a.y);});
            return f;
        }
        double intersection_area(const Point &a,const Point &b)const
        {
            bool ta=less_equal(distance(o,a),r),tb=less_equal(distance(o,b),r);
            if(ta&&tb) return cross(a-o,b-o)/2;
            vector<Point>t=cross_point(Line(b,a));
            if(ta&&!tb) return angle(t.front()-o,b-o)*r*r/2+cross(a-o,t.front()-o)/2;
            if(!ta&&tb) return angle(a-o,t.back()-o)*r*r/2+cross(t.back()-o,b-o)/2;
            double s=angle(a-o,b-o)*r*r/2;
            if(greater_equal(Line(a,b).distance(o),r)) return s;
            return s+angle(t.front()-o,t.back()-o)*r*r/2-cross(t.front()-o,t.back()-o)/2;
        }
        double intersection_area(const Polygon &g)const
        {
            int n=g.size();
            double s=0;
            for(int i=0;i<n;i++)
                s+=intersection_area(g[i],g[(i+1)%n]);
            return s;
        }
        double intersection_area(const Circle &c)const
        {
            double d=distance(o,c.o);
            if(greater(d,r+c.r)) return 0;
            if(less_equal(d,abs(r-c.r))) return min(area(),c.area());
            vector<Point>t=cross_point(c);
            double alpha=acos((d*d+r*r-c.r*c.r)/(2*d*r))*2,beta=acos((d*d+c.r*c.r-r*r)/(2*d*c.r))*2;
            double s1=alpha*r*r/2,s2=beta*c.r*c.r/2,s3=sin(alpha)*r*r/2+sin(beta)*c.r*c.r/2;
            return s1+s2-s3;
        }
    };
    const int SEPARATED=4,CIRCUMSCRIBED=3,INTERSECTED=2,INSCRIBED=1,INCLUDED=0;
    int intersection(const Circle &a,const Circle &b)
    {
        double d=distance(a.o,b.o);
        if(greater(d,a.r+b.r)) return SEPARATED;
        else if(equal(d,a.r+b.r)) return CIRCUMSCRIBED;
        else if(greater(d,abs(a.r-b.r))) return INTERSECTED;
        else if(equal(d,abs(a.r-b.r))) return INSCRIBED;
        else return INCLUDED;
    }
    class Triangle
    {
    public:
        Point A,B,C;
        Triangle(){}
        Triangle(const Point &_A,const Point &_B,const Point &_C):A(_A),B(_B),C(_C){}
        friend istream &operator>>(istream &in,Triangle &obj)
        {
            in>>obj.A>>obj.B>>obj.C;
            return in;
        }
        friend ostream &operator<<(ostream &out,const Triangle &obj)
        {
            out<<obj.A<<" "<<obj.B<<" "<<obj.C;
            return out;
        }
        Circle inscribed_circle()const
        {
            double a=distance(B,C),b=distance(A,C),c=distance(A,B);
            double p=(a+b+c)/2;
            double s=abs(cross(B-A,C-A))/2;
            double r=s/p;
            Point o((a*A.x+b*B.x+c*C.x)/(a+b+c),(a*A.y+b*B.y+c*C.y)/(a+b+c));
            return Circle(o,r);
        }
        Circle circumscribed_circle()const
        {
            double t1=A.x*A.x+A.y*A.y;
            double t2=B.x*B.x+B.y*B.y;
            double t3=C.x*C.x+C.y*C.y;
            double t=A.x*B.y+B.x*C.y+C.x*A.y-A.x*C.y-B.x*A.y-C.x*B.y;
            Point o((t2*C.y+t1*B.y+t3*A.y-t2*A.y-t3*B.y-t1*C.y)/t/2,(t3*B.x+t2*A.x+t1*C.x-t1*B.x-t2*C.x-t3*A.x)/t/2);
            double a=distance(B,C),b=distance(A,C),c=distance(A,B);
            double s=abs(cross(B-A,C-A))/2;
            double r=a*b*c/(4*s);
            return Circle(o,r);
        }
    };
    Circle smallest_enclosing_circle(const vector<Point> &_p)
    {
        vector<Point>p=_p;
        shuffle(p.begin(),p.end(),rnd);
        int n=p.size();
        Circle c=Circle(Point(0,0),0);
        for(int i=0;i<n;i++)
            if(c.point_containment(p[i])==OUT)
            {
                c=Circle(p[i],0);
                for(int j=0;j<i;j++)
                    if(c.point_containment(p[j])==OUT)
                    {
                        c=Circle((p[i]+p[j])/2,distance(p[i],p[j])/2);
                        for(int k=0;k<j;k++)
                            if(c.point_containment(p[k])==OUT)
                                c=Triangle(p[i],p[j],p[k]).circumscribed_circle();
                    }
            }
        return c;
    }
}
using namespace Geometry;
bool cmp(const Point &a,const Point &b)
{
    int x=a.quadrant(),y=b.quadrant();
    if(x!=y) return x<y;
    else return cross(a,b)>0;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr),cout.tie(nullptr);
    int n;
    cin>>n;
    vector<Circle>c(n);
    for(int i=0;i<n;i++)
    {
        int x,y,r;
        cin>>x>>y>>r;
        c[i]=Circle(Point(x,y),r);
    }
    Point q=Point(0,0);
    for(int i=0;i<n;i++)
        if(c[i].point_containment(q))
        {
            cout<<"Yes";
            return 0;
        }
    if(n==1)
    {
        cout<<"No";
        return 0;
    }
    vector<Point>p(n);
    for(int i=0;i<n;i++)
        p[i]=c[i].o;
    Polygon g=convex_hull(p);
    if(g.point_containment(q))
    {
        cout<<"Yes";
        return 0;
    }
    sort(c.begin(),c.end(),[=](const Circle &a,const Circle &b){return cmp(a.o,b.o);});
    for(int i=0;i<n;i++)
        if(c[i]!=c[(i+1)%n])
        {
            vector<Line>l=c[i].common_tangent_out(c[(i+1)%n]);
            if(l.empty()) continue;
            if((int)l.size()==1) continue;
            Line l1=l[0],l2=l[1];
            Polygon gg=vector<Point>{c[i].o,l1.a,l1.b,c[(i+1)%n].o,l2.b,l2.a};
            if(gg.point_containment(q))
            {
                cout<<"Yes";
                return 0;
            }
        }
    cout<<"No";
    return 0; 
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3864kb

input:

3
-3 0 1
0 0 3
3 0 1

output:

Yes

result:

ok answer is YES

Test #2:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

3
2 0 1
0 2 1
-5 -5 3

output:

Yes

result:

ok answer is YES

Test #3:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

1
3 3 1

output:

No

result:

ok answer is NO

Test #4:

score: 0
Accepted
time: 0ms
memory: 3724kb

input:

1
-3 -2 5

output:

Yes

result:

ok answer is YES

Test #5:

score: 0
Accepted
time: 0ms
memory: 3924kb

input:

2
1 3 5
-2 -6 1

output:

Yes

result:

ok answer is YES

Test #6:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

3
-14 7 7
2 -1 3
8 -1 9

output:

Yes

result:

ok answer is YES

Test #7:

score: 0
Accepted
time: 0ms
memory: 3788kb

input:

4
5 -3 9
-10 6 5
4 2 2
-8 10 2

output:

Yes

result:

ok answer is YES

Test #8:

score: 0
Accepted
time: 0ms
memory: 3720kb

input:

5
-2 -1 4
9 10 5
-9 2 4
6 -3 5
0 -4 10

output:

Yes

result:

ok answer is YES

Test #9:

score: 0
Accepted
time: 0ms
memory: 3764kb

input:

6
-3 -1 6
3 1 8
1 2 4
1 -3 5
3 7 4
5 5 4

output:

Yes

result:

ok answer is YES

Test #10:

score: 0
Accepted
time: 0ms
memory: 3724kb

input:

7
3 -2 5
-1 10 7
-1 10 3
1 -5 5
-9 -9 4
-5 -10 5
1 4 9

output:

Yes

result:

ok answer is YES

Test #11:

score: 0
Accepted
time: 0ms
memory: 3852kb

input:

8
3 -1 5
1 7 2
-2 -10 6
-1 6 4
-2 0 9
0 9 6
-7 1 7
5 -2 7

output:

Yes

result:

ok answer is YES

Test #12:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

9
-1 0 8
2 0 8
-8 -10 2
8 -2 1
-5 -8 0
-2 -3 5
-7 -4 9
-3 9 8
-10 10 7

output:

Yes

result:

ok answer is YES

Test #13:

score: 0
Accepted
time: 0ms
memory: 3788kb

input:

10
-3 0 4
3 -1 8
7 0 6
-6 -10 2
4 5 2
-7 -5 0
-7 4 7
10 7 0
-3 0 9
7 -6 6

output:

Yes

result:

ok answer is YES

Test #14:

score: 0
Accepted
time: 0ms
memory: 3716kb

input:

11
0 -4 7
5 9 4
-8 0 2
-10 8 5
7 9 1
7 8 8
4 -8 5
8 6 9
2 -7 8
3 4 0
10 -8 10

output:

Yes

result:

ok answer is YES

Test #15:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

12
2 3 5
-5 -9 5
5 -10 3
9 -10 9
-4 -10 0
10 5 1
-3 -5 7
2 10 10
0 7 10
-10 -7 5
-7 1 9
0 4 8

output:

Yes

result:

ok answer is YES

Test #16:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

13
3 0 5
-12 0 4
2 2 8
6 3 4
5 -3 0
3 -4 9
-9 5 9
-1 -3 5
4 -1 2
1 -3 10
-10 2 3
-7 9 7
-6 9 3

output:

Yes

result:

ok answer is YES

Test #17:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

14
2 1 4
8 -3 0
-7 -4 2
10 -6 5
-4 -4 4
1 1 2
4 6 5
-3 -5 5
10 -10 1
4 -6 2
-4 9 3
-3 10 8
-6 6 10
8 -8 1

output:

Yes

result:

ok answer is YES

Test #18:

score: 0
Accepted
time: 0ms
memory: 3708kb

input:

15
1 2 6
-1 -2 3
9 -10 2
0 5 6
8 10 8
-2 -6 9
-7 4 0
6 -10 1
-6 -3 10
7 -3 2
5 -9 5
10 0 3
9 -6 1
0 -1 3
-8 -3 5

output:

Yes

result:

ok answer is YES

Test #19:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

16
0 -8 9
1 -4 0
-8 -3 7
-6 -7 7
3 -7 9
-9 7 10
4 1 1
-9 2 7
1 -7 7
-5 -3 3
4 4 3
-1 -9 2
-4 -1 7
-8 -2 10
-6 1 3
-1 -8 3

output:

Yes

result:

ok answer is YES

Test #20:

score: 0
Accepted
time: 0ms
memory: 3772kb

input:

17
0 4 7
-6 8 0
6 6 4
3 -8 7
-6 2 6
-10 8 3
-10 9 8
-9 1 9
-10 8 2
-9 0 7
-5 1 1
2 -4 5
-3 -5 0
-4 0 6
1 -2 0
6 -4 4
-2 -7 3

output:

Yes

result:

ok answer is YES

Test #21:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

18
-3 -3 1
5 5 8
7 -6 8
-10 3 4
10 1 2
7 -10 10
3 -4 9
1 5 6
-10 -4 1
3 -4 2
4 -5 9
3 -6 4
3 1 7
9 -3 5
6 9 8
5 -6 2
9 -2 5
10 3 2

output:

Yes

result:

ok answer is YES

Test #22:

score: 0
Accepted
time: 0ms
memory: 3724kb

input:

19
4 -1 8
-5 5 1
-5 -4 7
-9 -10 7
-8 6 0
10 10 6
2 -6 9
1 1 6
-9 -6 7
-8 -5 5
2 -7 9
1 -1 4
-7 4 5
-3 3 10
1 6 6
2 4 6
-7 3 10
-5 -4 8
9 -4 6

output:

Yes

result:

ok answer is YES

Test #23:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

20
1 0 2
-10 3 7
9 -3 7
0 -10 7
7 -6 8
-5 6 7
5 6 5
7 8 8
-4 -10 9
-8 -10 8
2 -5 5
-5 -5 9
-5 9 10
1 9 1
-7 6 4
0 -1 6
-5 7 9
-1 -4 5
-4 4 6
3 6 2

output:

Yes

result:

ok answer is YES

Test #24:

score: 0
Accepted
time: 0ms
memory: 3764kb

input:

3
-6 -6 2
-10 -8 8
-7 -7 5

output:

No

result:

ok answer is NO

Test #25:

score: 0
Accepted
time: 0ms
memory: 3860kb

input:

4
-7 -9 3
-3 -6 2
9 -1 2
0 -7 3

output:

No

result:

ok answer is NO

Test #26:

score: 0
Accepted
time: 0ms
memory: 3860kb

input:

5
2 -6 3
-2 -8 2
-3 -5 1
-5 -9 1
0 -7 1

output:

No

result:

ok answer is NO

Test #27:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

6
10 9 6
7 10 3
6 10 8
3 7 3
-4 8 3
7 5 4

output:

No

result:

ok answer is NO

Test #28:

score: 0
Accepted
time: 0ms
memory: 3676kb

input:

7
-9 8 6
-8 1 4
-10 -1 1
-7 10 4
-5 9 1
-8 10 6
-10 9 5

output:

No

result:

ok answer is NO

Test #29:

score: 0
Accepted
time: 0ms
memory: 3680kb

input:

8
0 -8 3
9 -10 7
5 -7 1
4 -7 2
3 -7 5
0 -5 1
3 -7 2
2 -7 4

output:

No

result:

ok answer is NO

Test #30:

score: 0
Accepted
time: 0ms
memory: 3860kb

input:

9
-1 -9 3
7 -7 2
10 0 1
-8 -10 2
-5 -10 1
8 -4 2
8 -9 5
8 -5 4
8 -7 3

output:

No

result:

ok answer is NO

Test #31:

score: 0
Accepted
time: 0ms
memory: 3784kb

input:

10
-7 -8 1
-7 -9 3
-7 1 1
-7 -1 1
-6 3 2
-10 6 3
-10 -9 2
-6 2 1
-8 -9 3
-5 -3 1

output:

No

result:

ok answer is NO

Test #32:

score: 0
Accepted
time: 0ms
memory: 3708kb

input:

11
-7 -3 4
1 -10 3
-10 -5 5
-7 -7 4
-10 2 1
0 -8 1
-4 -4 2
-10 -3 3
-6 -7 5
-6 -8 3
2 -10 2

output:

No

result:

ok answer is NO

Test #33:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

12
-8 10 4
-8 8 5
-9 8 3
-9 9 6
1 7 3
-6 8 7
1 9 2
1 7 2
-6 8 3
-7 0 1
-3 6 4
2 10 2

output:

No

result:

ok answer is NO

Test #34:

score: 0
Accepted
time: 0ms
memory: 3768kb

input:

13
-7 -1 1
-6 3 4
-9 8 7
1 9 1
-10 9 7
-5 9 6
-1 10 4
-5 4 4
-8 7 1
0 6 1
-9 0 4
-1 6 1
-8 10 5

output:

No

result:

ok answer is NO

Test #35:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

14
-8 -6 1
-9 -6 2
-6 3 3
-10 7 7
-7 9 8
-6 6 2
-10 5 9
-7 -1 3
0 8 1
-9 10 9
-10 -10 1
-6 5 4
-10 7 6
-2 8 1

output:

No

result:

ok answer is NO

Test #36:

score: 0
Accepted
time: 0ms
memory: 3856kb

input:

15
9 7 5
9 10 6
9 1 4
9 4 7
10 7 2
10 0 1
9 9 9
9 10 5
8 4 5
9 -2 4
7 -2 3
9 7 3
3 1 1
7 9 1
7 4 5

output:

No

result:

ok answer is NO

Test #37:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

16
-8 10 5
-9 10 2
-10 -2 2
-8 1 2
-5 -5 2
-10 1 6
-6 9 2
-8 4 1
-7 -5 4
-7 5 2
-9 -8 2
-10 -9 2
-8 -8 4
-8 -1 5
-6 -9 2
-7 5 1

output:

No

result:

ok answer is NO

Test #38:

score: 0
Accepted
time: 0ms
memory: 3860kb

input:

17
-8 -8 2
-10 3 5
-3 -7 2
-6 -6 5
-8 0 4
-2 -10 3
-9 -9 1
-9 -5 2
-9 4 3
-8 -3 2
-7 -6 1
-8 3 3
-5 -8 2
-6 -2 1
-6 1 2
-10 5 3
-5 -2 1

output:

No

result:

ok answer is NO

Test #39:

score: 0
Accepted
time: 0ms
memory: 3772kb

input:

18
4 -2 1
7 -10 1
9 -6 2
7 9 5
9 8 6
9 2 4
10 3 4
7 9 7
8 7 5
6 1 1
4 -2 1
9 0 4
7 10 7
5 3 3
2 7 2
4 6 3
10 -5 5
8 0 4

output:

No

result:

ok answer is NO

Test #40:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

19
-2 10 4
10 9 2
-4 7 3
1 8 4
-7 2 2
-10 3 2
5 6 1
-3 10 6
-7 7 5
-2 10 8
-10 8 4
-3 5 3
-3 9 2
4 8 4
7 8 3
-8 4 1
4 10 1
9 7 1
-2 6 2

output:

No

result:

ok answer is NO

Test #41:

score: 0
Accepted
time: 0ms
memory: 3792kb

input:

20
9 7 4
9 6 1
-9 8 2
1 9 6
3 8 3
1 7 2
4 6 2
2 9 7
-5 7 1
9 3 2
-1 9 4
5 5 3
-10 9 3
1 9 1
-7 8 1
7 9 3
10 10 9
5 8 3
1 5 1
-7 10 1

output:

No

result:

ok answer is NO

Test #42:

score: 0
Accepted
time: 0ms
memory: 3656kb

input:

490
-401120 517405 392832
80224 -103481 797533
754989 -41760 559341
416563 -695192 201277
-141668 -665827 898034
-236708 -535297 871413
993788 606278 381486
589063 -611773 228296
-919383 718355 908770
-657978 42950 738469
-304514 -146524 532007
433672 -184231 820655
-142774 -3858 384901
-879148 1653...

output:

Yes

result:

ok answer is YES

Test #43:

score: 0
Accepted
time: 0ms
memory: 3860kb

input:

491
-872659 -699808 892915
872659 699808 991810
659525 -631701 442804
-305260 788091 674223
-246189 -657824 701213
-486340 702251 412375
943552 -220491 91527
835536 759608 489761
-165917 716863 320734
-544207 -167639 633696
863791 16438 917784
797655 370791 426650
-455839 649078 942747
-440922 -7269...

output:

Yes

result:

ok answer is YES

Test #44:

score: 0
Accepted
time: 0ms
memory: 3944kb

input:

492
85070 -163392 274400
-425350 816960 79480
830750 922585 987668
894794 -69053 51789
746578 846338 169004
725416 -943389 613749
157359 442389 642057
856229 539565 355115
-98088 -94634 464783
-7867 -406308 801658
-133127 -884007 341601
645211 455900 647745
283048 445596 350027
828628 -554092 314351...

output:

Yes

result:

ok answer is YES

Test #45:

score: 0
Accepted
time: 0ms
memory: 3660kb

input:

493
-337499 -223669 204963
337499 223669 175181
-62568 -997282 924216
-785855 -790106 508347
-504113 926160 207804
-811011 143840 746657
299819 -274530 253669
81562 70497 364775
-992771 -63630 158939
240722 -191363 990373
68483 -299216 580892
125440 -878042 60112
564463 -493982 902303
-582047 -50698...

output:

Yes

result:

ok answer is YES

Test #46:

score: 0
Accepted
time: 0ms
memory: 3788kb

input:

494
278560 196119 494170
-835680 -588357 732997
613605 -784073 726646
896480 648928 377870
630656 -778834 785049
95978 -274271 323791
952706 -309202 822553
-118178 -765503 915366
-409835 470311 188171
244173 723222 486152
585735 349683 511310
794978 708028 551980
283009 -544485 17144
-489404 -55428 ...

output:

Yes

result:

ok answer is YES

Test #47:

score: 0
Accepted
time: 0ms
memory: 3876kb

input:

495
166424 -9538 213430
-918208 12496 312838
-553881 -141147 169771
-862671 180067 594468
-869538 -459958 791131
203963 -46925 673657
792949 905244 132725
-244283 36408 283748
-702543 -547763 551168
307437 137180 567371
-825875 -653582 267833
-631352 770632 418429
-16415 -658120 746828
-64666 -58802...

output:

Yes

result:

ok answer is YES

Test #48:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

496
141268 -980616 572051
-35317 245154 169086
-347003 -269510 425841
301475 9661 617109
50389 520735 575503
-379867 -355207 88273
914615 550032 194184
341380 -90691 58960
-881531 926153 941231
-935000 418250 384889
-66455 76375 149388
262359 -608680 244962
-648253 -456285 187461
-424908 948435 4146...

output:

Yes

result:

ok answer is YES

Test #49:

score: 0
Accepted
time: 0ms
memory: 3744kb

input:

497
-485048 834780 656812
242524 -417390 975403
87235 564073 339746
-440124 -4377 554520
556890 252197 524586
-97029 -336887 637628
-693086 -572966 537693
-937215 -295332 818169
661581 -542414 928902
-702501 -476007 661734
-501428 -974254 595982
788266 -154126 996801
262451 -70362 269240
-64749 3040...

output:

Yes

result:

ok answer is YES

Test #50:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

498
63374 167580 194225
-226071 -758060 212291
-243179 401960 871253
632017 -974472 774851
-775638 434525 257145
523264 -540226 852177
-118921 -609603 361540
536935 -960950 998211
-779714 820637 150783
-130275 -464805 348441
929369 -957670 242705
147736 880691 143486
993451 -101779 114756
161981 -22...

output:

Yes

result:

ok answer is YES

Test #51:

score: 0
Accepted
time: 0ms
memory: 3776kb

input:

499
85385 -63451 71318
-170770 126902 563893
256536 487293 697550
-13786 580255 476072
-736160 21495 342847
-512540 -596790 20229
414967 -752637 33406
-241751 818909 36982
-189497 831393 760606
-760839 -52270 815865
-426433 476785 751461
811316 -805777 619598
-175099 -59090 281702
342361 -219269 999...

output:

Yes

result:

ok answer is YES

Test #52:

score: 0
Accepted
time: 0ms
memory: 3660kb

input:

500
-546618 156961 709962
900993 -979479 482300
-278234 745342 850180
-575239 -972802 40718
-311366 -205433 176044
-533631 703878 841930
148899 -585743 772676
485273 813709 392242
-879325 -635405 21200
487413 810421 69597
634966 771073 85875
905717 711266 931353
-510826 -168951 658710
-942024 -46634...

output:

Yes

result:

ok answer is YES

Test #53:

score: 0
Accepted
time: 1ms
memory: 3708kb

input:

501
719919 -109933 580601
662951 -723491 144244
574654 470175 668547
46421 729922 163745
700192 654929 755179
782717 378301 328766
862814 706616 346048
667904 -111318 156500
579368 137888 389074
-223390 923203 162053
584358 162237 505492
709352 -567378 114068
955894 570460 182478
231455 479087 29651...

output:

No

result:

ok answer is NO

Test #54:

score: 0
Accepted
time: 1ms
memory: 3804kb

input:

502
-542839 708327 62660
643693 517978 191446
-991100 906326 864835
-836020 604539 761976
352407 957558 781072
623790 964065 221671
353653 814961 539083
815286 717558 272871
-369827 990361 995847
-232962 336932 40976
-830578 450241 450919
232969 713634 338349
-768021 117784 210529
-884431 752672 900...

output:

No

result:

ok answer is NO

Test #55:

score: 0
Accepted
time: 1ms
memory: 3744kb

input:

503
-801414 -816922 923240
114323 -487866 361316
-743557 -730530 84140
-829301 -940494 807526
-235116 -344584 278498
-330955 -688281 451006
823626 -968076 90701
140980 -977705 451422
-814268 -851220 131290
-846941 -593459 896059
533705 -400215 69124
4587 -881760 558754
-802148 -206717 471528
-827283...

output:

No

result:

ok answer is NO

Test #56:

score: 0
Accepted
time: 0ms
memory: 3804kb

input:

504
755986 -962938 477675
891435 161731 768926
651367 929621 797424
994214 406037 789405
869430 246620 796884
298255 776330 449780
684371 333684 262247
670018 -386007 528154
839288 684632 812558
620407 -4026 479691
710344 636254 747431
880645 443922 823996
545394 669267 367679
954478 -173336 440290
...

output:

No

result:

ok answer is NO

Test #57:

score: 0
Accepted
time: 1ms
memory: 3812kb

input:

505
-188345 489261 91972
-838692 449950 73753
-507512 859824 536002
-570714 -530385 24316
-992917 -414763 404589
-769946 488098 568394
-960983 -276584 346160
-469075 861641 363934
-225052 790076 243313
-722523 682968 736186
-705870 -151620 73515
-253605 748468 362614
-96450 592060 298637
-634236 496...

output:

No

result:

ok answer is NO

Test #58:

score: 0
Accepted
time: 1ms
memory: 3804kb

input:

506
-991184 297267 584267
-705982 277942 1065
-250745 -390214 204672
-393508 -214627 179589
-958688 -888068 794448
-516532 576831 395195
-988396 941347 899401
-565796 -322663 32695
-790534 -385333 324893
-982163 176608 403904
-383275 482847 134272
-419897 -23826 178891
-505196 -180556 211459
-581310...

output:

No

result:

ok answer is NO

Test #59:

score: 0
Accepted
time: 1ms
memory: 3680kb

input:

507
957466 -893009 657902
946567 -461425 132058
866624 -961067 558142
967631 -785998 964132
132931 -721390 468056
599622 -250008 121529
961871 -23870 373404
834486 -829987 823485
675991 -654952 930203
645837 -483179 731928
735102 -169255 135454
-479297 -619736 43869
507074 -602690 363742
942896 -698...

output:

No

result:

ok answer is NO

Test #60:

score: 0
Accepted
time: 1ms
memory: 3956kb

input:

508
-918402 181440 492694
236130 -833328 174932
-723003 -477614 521215
665428 -984644 37654
-240903 -935817 703085
-864937 -475078 340552
-430885 -37818 321227
-86351 -272110 243498
-816965 50300 354919
-64843 -648405 458407
-328717 -900821 550767
-150306 -77761 63647
-697455 -867881 739891
-991104 ...

output:

No

result:

ok answer is NO

Test #61:

score: 0
Accepted
time: 1ms
memory: 3808kb

input:

509
398716 -826995 314578
653383 -815130 960623
671993 210091 410118
464699 12210 168309
557108 625896 18608
897224 -678674 183824
879526 33628 314845
992567 714989 450134
424784 -336791 491419
855349 -161348 669505
-37459 -592576 244387
847711 807155 221027
180814 -323267 153533
238277 -559117 2491...

output:

No

result:

ok answer is NO

Test #62:

score: 0
Accepted
time: 1ms
memory: 3888kb

input:

510
272589 761937 599208
750859 334201 361715
-372530 901376 595843
515116 455432 448895
532437 772848 699316
963939 658604 259172
487479 647146 281810
-884317 858708 606880
-891432 935016 448672
-407506 483130 127141
-349522 932045 683844
675223 835840 412454
-286098 620046 438863
-441288 93623 396...

output:

No

result:

ok answer is NO

Test #63:

score: 0
Accepted
time: 146ms
memory: 26692kb

input:

999990
45820 -322596 820456
-874008 -836611 762874
616366 686996 25392
-881827 760597 644853
57064 -174625 716463
-509069 636387 187237
-693286 712638 916997
-33799 483599 987678
214934 741811 414850
-410211 -854929 474517
-599014 986603 796760
866348 -86841 381213
969124 853275 271319
-675321 -4469...

output:

Yes

result:

ok answer is YES

Test #64:

score: 0
Accepted
time: 150ms
memory: 26900kb

input:

999991
130284 -139478 574815
-842927 98341 618774
-993032 861315 326208
-470724 -722102 436311
788514 -956229 881655
-361944 653064 243855
719927 418967 153488
-382317 596732 789
-931300 -241341 292569
350704 728196 642200
435795 365691 727783
-707752 -841280 391730
-531710 553285 441690
935209 3205...

output:

Yes

result:

ok answer is YES

Test #65:

score: 0
Accepted
time: 141ms
memory: 26796kb

input:

999992
-364864 -346696 683513
-132986 -83128 125202
682169 994565 486357
766778 568446 44484
-34939 -135978 146885
-451085 167829 977496
414449 -119429 190393
-939591 -386310 682812
937272 -539210 214853
728916 106890 47162
867408 -862718 181313
-487791 -932334 437587
-252507 -281927 4565
-387686 -6...

output:

Yes

result:

ok answer is YES

Test #66:

score: 0
Accepted
time: 155ms
memory: 26772kb

input:

999993
-974422 -157045 965243
974422 157045 747552
-366444 -90585 962464
845148 881428 533394
275676 -516841 499876
-458669 719946 431860
867904 192331 779653
-549066 -85749 482238
-845984 -595006 524669
709551 832741 253532
429524 499062 48051
75273 367711 265689
-216994 -478811 433408
-928083 5440...

output:

Yes

result:

ok answer is YES

Test #67:

score: 0
Accepted
time: 150ms
memory: 26836kb

input:

999994
-43013 -81745 141557
-879737 -826422 400178
979447 -264465 223198
-598402 331991 248329
869287 447337 294580
841198 988573 632208
822307 -402049 542782
658381 -564445 122620
-680723 15730 732860
845196 356385 302322
-651223 -110463 550151
798642 -199856 891062
-657627 -550010 518339
620185 -1...

output:

Yes

result:

ok answer is YES

Test #68:

score: 0
Accepted
time: 154ms
memory: 26764kb

input:

999995
686356 -70469 824822
211885 -32903 337285
696298 628674 500831
-719585 686431 329702
638284 373058 347221
-388172 -156549 319508
436585 593535 499547
678673 621752 547292
810258 -871682 877200
839391 -236551 244104
-689950 -194614 773616
916396 251841 404334
-535426 -278998 752060
800135 -896...

output:

Yes

result:

ok answer is YES

Test #69:

score: 0
Accepted
time: 150ms
memory: 26900kb

input:

999996
-170809 -557633 72558
170809 557633 611577
-56161 -188232 394245
296764 449733 622055
786338 197011 198842
-951567 974227 796944
5856 -90932 923862
313089 93099 900082
319254 311302 354336
-779484 216352 124881
258463 -456644 382907
-237688 -257469 999837
-184546 788388 503846
110977 206227 4...

output:

Yes

result:

ok answer is YES

Test #70:

score: 0
Accepted
time: 149ms
memory: 26780kb

input:

999997
48912 62148 348088
-299751 395133 240963
72113 -225761 921915
538862 -390619 20989
849395 801257 360036
-611460 -858148 156881
941320 -75037 948413
-480351 -732563 14061
-753060 190728 661974
-704623 -971229 879005
995079 -641480 831966
388103 -141837 519952
620946 856523 430130
-463570 -4259...

output:

Yes

result:

ok answer is YES

Test #71:

score: 0
Accepted
time: 159ms
memory: 26860kb

input:

999998
-117412 -401256 546791
712605 -955241 35771
-593413 -14238 890708
-69563 -587277 430045
323110 -461491 760852
-531156 569047 504193
559207 -179700 290629
422590 696403 251456
-192719 -716740 74724
-677405 -207593 760079
-328051 -527802 295581
444896 472252 729602
-238148 425064 301038
-243357...

output:

Yes

result:

ok answer is YES

Test #72:

score: 0
Accepted
time: 143ms
memory: 26952kb

input:

999999
-74193 131181 448857
74193 -131181 249613
-908956 -475003 727013
-184745 -256518 264584
949557 -410856 59573
-527967 991954 998886
982911 -96437 287554
-460349 -185247 749115
-239158 448505 226081
44935 -565053 137061
843217 -221346 877142
619480 -496720 174106
-776632 -30765 297555
-321708 9...

output:

Yes

result:

ok answer is YES

Test #73:

score: 0
Accepted
time: 150ms
memory: 26812kb

input:

1000000
-6563 -34143 747250
6563 34143 64141
205367 712733 870642
737609 356028 633261
278460 460276 959662
-600298 339653 891713
508334 480434 191798
-672818 338051 16689
-187342 664355 65322
351772 45313 576301
129388 -457461 674453
28456 96302 566510
552923 508403 560123
-726877 355154 173296
-23...

output:

Yes

result:

ok answer is YES

Test #74:

score: 0
Accepted
time: 546ms
memory: 58048kb

input:

999990
227268 633750 101511
-776883 991092 562670
-845660 981057 386764
-671211 81361 60206
-76057 528489 256389
-482572 990861 2167
-257518 857464 534454
-579503 223024 401558
-918072 -156299 159559
-820878 -386109 313493
-258853 753913 300639
-985454 -719239 37134
-814165 738967 55826
-801999 -466...

output:

No

result:

ok answer is NO

Test #75:

score: 0
Accepted
time: 582ms
memory: 58188kb

input:

999991
-803919 539509 22841
-299618 803855 559335
-943727 626076 755108
-805118 -517869 70113
-483568 690752 523734
-930042 349654 52165
-106964 556198 265060
-937436 489107 611703
-584577 333057 406178
-327381 229902 342963
-373542 913332 506055
-854930 -248567 387106
-172645 386422 157658
-904146 ...

output:

No

result:

ok answer is NO

Test #76:

score: 0
Accepted
time: 535ms
memory: 58104kb

input:

999992
4332 302599 271948
621367 363492 17410
545903 871154 678458
852610 855514 121610
-167463 392444 227297
448101 673161 27980
226850 684933 99597
-630308 288165 349424
-567325 413394 214583
-793472 881305 901308
185246 820982 421113
-768970 635045 626799
540357 511183 179670
100303 510777 360627...

output:

No

result:

ok answer is NO

Test #77:

score: 0
Accepted
time: 549ms
memory: 58080kb

input:

999993
-665462 -12836 370181
-984529 487404 884376
-904897 171698 685643
-882162 366394 28986
-875309 571549 921724
-655960 -936909 38558
-473840 496449 279680
-879807 575760 505235
-775745 583885 667407
-492474 209621 472540
-909526 354207 482909
-361350 183766 158244
-748903 492943 631062
-733051 ...

output:

No

result:

ok answer is NO

Test #78:

score: 0
Accepted
time: 541ms
memory: 57900kb

input:

999994
-782276 -517381 514275
-798653 652285 13059
-703251 699049 788084
-505362 -608909 160775
-895655 864610 926944
-365686 669353 153878
-424444 876285 182265
-719900 72860 32036
-538035 652712 510166
-183748 -147990 116767
-831245 793066 241588
-302722 368381 256949
-657930 505685 535809
-785812...

output:

No

result:

ok answer is NO

Test #79:

score: 0
Accepted
time: 561ms
memory: 58212kb

input:

999995
671887 279201 87331
443750 294422 73524
668036 306922 161167
837023 261024 472266
805285 -702229 88951
830536 -784159 846155
201925 -118236 120405
580025 -887122 28162
132095 -947814 411517
351097 -158067 258600
-322536 -983762 49875
878863 285 633698
839829 -9476 515534
703673 210237 383337
...

output:

No

result:

ok answer is NO

Test #80:

score: 0
Accepted
time: 531ms
memory: 57980kb

input:

999996
904575 781824 957706
789009 801121 518097
937132 882752 197693
226070 639103 152437
458867 213650 217401
-77106 959454 68166
417940 255385 175702
785653 -530512 149232
88710 362781 50051
879188 35670 314885
459060 383723 524895
496172 565944 140392
-131882 898801 44890
-189516 898019 126578
6...

output:

No

result:

ok answer is NO

Test #81:

score: 0
Accepted
time: 552ms
memory: 57912kb

input:

999997
280114 -813809 288102
880384 -927409 349394
925536 -715148 191889
974095 551121 486140
398876 -519577 250089
455448 -498437 556053
876630 684291 40749
982824 744999 324679
703832 -354136 571054
979491 -381311 476003
982968 395755 218979
947186 -890441 204419
970575 84691 175102
874480 -366091...

output:

No

result:

ok answer is NO

Test #82:

score: 0
Accepted
time: 519ms
memory: 58092kb

input:

999998
966150 791571 91795
498970 483833 247692
-363739 992109 399731
156361 303908 216608
-414028 922023 209510
836879 148570 120586
894920 668067 870098
-320758 670835 250037
-118486 961821 278665
737708 -162902 309093
869190 438247 83562
-98971 587596 81142
-160386 672747 313982
860051 918235 807...

output:

No

result:

ok answer is NO

Test #83:

score: 0
Accepted
time: 536ms
memory: 58164kb

input:

999999
322944 624862 319817
281246 396544 378532
-518445 544410 86920
663325 873330 188117
-880600 909379 250709
803853 828210 832805
262683 651389 77505
427138 856870 107069
-729989 935186 124276
505538 581606 286978
406313 242561 383411
961230 525759 385111
751745 865841 255259
972532 757834 15889...

output:

No

result:

ok answer is NO

Test #84:

score: 0
Accepted
time: 552ms
memory: 57932kb

input:

1000000
-506204 -41417 18303
-24339 -855603 117864
-694447 -620550 41666
70012 -996074 871101
-225484 -240423 224068
-401982 -973429 62033
-443022 -711122 708734
-872443 -511501 467161
-124146 -964336 895917
-931925 -662237 507004
-100635 -906885 178087
-79181 -478800 143766
-805124 -179484 23851
-5...

output:

No

result:

ok answer is NO

Test #85:

score: 0
Accepted
time: 255ms
memory: 57916kb

input:

999990
478024 330473 58154
969655 742685 389651
176366 554080 145402
715966 736246 106721
5604 936262 132181
885748 432562 226909
118061 620797 16428
662577 806726 96645
673603 930620 322071
916533 725176 209549
981955 975038 29834
585183 795560 439465
-3939 535813 67879
968395 877517 592205
874684 ...

output:

Yes

result:

ok answer is YES

Test #86:

score: 0
Accepted
time: 251ms
memory: 58160kb

input:

999991
521745 368094 22578
867877 928013 457708
798042 400369 162253
323782 647425 5819
293226 869029 204540
192551 83996 13898
889197 751615 184816
905410 751437 382830
575690 761561 636914
164150 884413 75218
238075 709248 301973
577678 663516 210531
859065 674223 449638
943639 783637 405404
63614...

output:

Yes

result:

ok answer is YES

Test #87:

score: 0
Accepted
time: 262ms
memory: 57988kb

input:

999992
878399 877198 10272
966634 27470 442812
877313 -384275 46166
813361 89276 1749
758002 331133 38133
855894 -170092 69354
492085 303396 202753
442751 292272 152347
729794 624726 36183
724758 813102 51855
760542 -19373 58057
358664 32707 96675
713080 -215754 43953
278404 197582 12376
682136 1396...

output:

Yes

result:

ok answer is YES

Test #88:

score: 0
Accepted
time: 255ms
memory: 58196kb

input:

999993
652185 664823 269670
920948 675321 160292
869623 407431 96660
66228 613673 235107
932437 573105 104269
461394 929996 501903
274667 334487 215429
438557 645583 339016
765540 804176 240388
312249 718304 215331
142442 491031 230555
395865 962187 396321
105901 912041 388798
895010 600777 83982
29...

output:

Yes

result:

ok answer is YES

Test #89:

score: 0
Accepted
time: 260ms
memory: 58100kb

input:

999994
448303 939559 442859
61136 550114 115864
150026 775929 328072
651446 937439 445571
318856 864804 392297
356506 583114 110281
117433 923369 47745
334745 880138 8810
228020 510232 104250
577235 836162 282439
587382 970729 495733
-285566 607425 37425
842937 975634 21623
631104 615350 144027
-158...

output:

Yes

result:

ok answer is YES

Test #90:

score: 0
Accepted
time: 259ms
memory: 58184kb

input:

999995
-559679 -838950 649485
-886096 -583178 436161
-492126 -548412 388816
-427227 -496376 132111
-357921 -704129 1728
-899887 -637389 33139
-885664 -887367 235747
-283474 -847364 52610
-841957 -641389 132754
-998808 -678636 526955
16098 -758190 24820
-266783 -603527 68084
-544564 -855189 320388
-8...

output:

Yes

result:

ok answer is YES

Test #91:

score: 0
Accepted
time: 259ms
memory: 57896kb

input:

999996
722888 -757230 78396
132924 -289393 10847
430406 -556972 354920
712608 -882836 107854
330325 -610063 486
976028 -364591 146348
719112 -759088 91197
974516 -917656 390898
448880 -944143 348167
814453 -677176 403659
688012 -958896 94355
325356 -330147 125292
958666 -942632 350176
294917 -678188...

output:

Yes

result:

ok answer is YES

Test #92:

score: 0
Accepted
time: 263ms
memory: 57996kb

input:

999997
-921553 -868753 13379
-175402 -298764 106648
-380752 -714998 97860
-411233 -620318 260111
-883599 -964164 53224
63746 -924808 22736
-989988 -983289 256811
-184155 -711390 20170
-937618 -762774 479705
-662664 -988785 387663
-532200 -914087 440965
-891516 -969169 668287
-673561 -554686 387794
-...

output:

Yes

result:

ok answer is YES

Test #93:

score: 0
Accepted
time: 260ms
memory: 57896kb

input:

999998
589435 -879992 219062
760878 -191575 229425
482674 -428251 327910
323000 -648425 150312
991319 -674298 397030
871714 -612406 291591
946629 -993758 533779
970371 -701622 258943
399273 -553956 216845
574365 -264058 81781
840281 -930297 298621
506429 -236273 59590
590937 -686986 443923
484348 -9...

output:

Yes

result:

ok answer is YES

Test #94:

score: 0
Accepted
time: 260ms
memory: 58124kb

input:

999999
556518 25631 19171
674007 -858513 35283
709179 -350212 277
557646 -835041 33464
999291 -755515 360969
183614 -263462 58075
265628 -139066 145211
549318 -160942 241775
378707 -268205 101745
658023 -441182 502712
811280 -289698 351105
627769 -251683 251901
891171 -374010 100948
596675 -541651 1...

output:

Yes

result:

ok answer is YES

Test #95:

score: 0
Accepted
time: 258ms
memory: 57896kb

input:

1000000
-467734 -10176 140177
-618405 162107 169340
-383227 355845 128283
-960623 344722 580735
-141876 109557 40900
-879304 -304306 70709
-361000 301727 31272
-498022 323681 31538
-848656 151033 269909
-572593 -20611 70951
-785868 810455 99413
-699664 -26521 311317
-934830 506329 381878
-908564 872...

output:

Yes

result:

ok answer is YES