QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#317640#5067. Two Wallslmf_upWA 251ms4104kbC++2018.8kb2024-01-29 10:56:582024-01-29 10:56:58

Judging History

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

  • [2024-01-29 10:56:58]
  • 评测
  • 测评结果:WA
  • 用时:251ms
  • 内存:4104kb
  • [2024-01-29 10:56:58]
  • 提交

answer

#include<bits/stdc++.h>

#define cp const point &
#define cl const line &
#define cc const circle &
#define LD long double
std::mt19937 rnd(time(0));
const LD eps = 1e-8;
const LD pi = std::numbers::pi;
const LD INF = 1e9;

int sgn(LD x)
{
    return x > eps ? 1 : (x < -eps ? -1 : 0);
}

LD sqr(LD x)
{ return x * x; }

struct point
{
    LD x, y;

    point operator+(cp a) const
    { return {x + a.x, y + a.y}; }

    point operator-(cp a) const
    { return {x - a.x, y - a.y}; }

    point operator*(LD t) const
    { return {x * t, y * t}; }

    point operator/(LD t) const
    { return {x / t, y / t}; }

    point rot(LD t) const
    { return {(LD)(x * cos(t) - y * sin(t)), (LD)(x * sin(t) + y * cos(t))}; }

    point rot90() const
    { return {-y, x}; }

    LD len2() const
    { return x * x + y * y; }

    LD len() const
    { return sqrtl(x * x + y * y); }

    point unit() const
    {
        double d = len();
        return {(LD)(x / d), (LD)(y / d)};
    }
    int on_up()//b不判(0,0)
    {
        return sgn(y)==1||(sgn(y)==0&&sgn(x)>0);
    }
    void print()
    {
        std::cout<<x<<' '<<y<<std::endl;
    }
    void read()
    {
        std::cin>>x>>y;
    }
    friend bool operator<(cp a, cp b)
    {
        return a.x == b.x ? a.y < b.y : a.x < b.x;
    }

    friend bool operator>(cp a, cp b)
    {
        return a.x == b.x ? a.y > b.y : a.x > b.x;
    }
};

LD dot(cp a, cp b);

bool operator==(cp a, cp b)
{
    return !sgn(dot(a - b, a - b));
}

LD dis(cp a, cp b)//两点距离
{
    return sqrtl(sqr(a.x - b.x) + sqr(a.y - b.y));
}

LD dot(cp a, cp b)//点乘
{
    return a.x * b.x + a.y * b.y;
}

LD det(cp a, cp b)//叉乘
{
    return a.x * b.y - b.x * a.y;
}

bool turn_left(cp a, cp b, cp c)//判断ba是否逆时针转少于180°到ca
{
    return sgn(det(b - a, c - a)) > 0;//大于是严格凸包
}

struct line
{
    point s, t;
    line() {}
    line(point a, point b) : s(a), t(b)
    {}
    void read()
    {
        s.read(),t.read();
    }
    void print()
    {
        s.print(),std::cout<<' ',t.print();
    }

};

struct circle
{
    point c;
    LD r;

    circle()
    {}

    circle(point C, LD R)
    { c = C, r = R; }
};

bool in_circle(cp a, cc b)
{
    return sgn((b.c - a).len() - b.r) <= 0;
}

circle make_circle(point u, point v)
{
    point p = (u + v) / 2;
    return circle(p, (u - p).len());
}

circle make_circle(cp a, cp b, cp c)
{
    point p = b - a, q = c - a;
    point s(dot(p, p) / 2, dot(q, q) / 2);
    LD d = det(p, q);
    p = point(det(s, point(p.y, q.y)), det(point(p.x, q.x), s)) / d;
    return circle(a + p, p.len());
}

circle min_circle(std::vector<point> p)
{
    circle ret(p[0], 0);
    std::shuffle(p.begin(), p.end(), rnd);
    int len = p.size();
    for (int i = 0; i < len; i++)
        if (!in_circle(p[i], ret))
        {
            ret = circle(p[i], 0);
            for (int j = 0; j < i; j++)
                if (!in_circle(p[j], ret))
                {
                    ret = make_circle(p[j], p[i]);
                    for (int k = 0; k < j; ++k)
                        if (!in_circle(p[k], ret))
                            ret = make_circle(p[i], p[j], p[k]);
                }
        }
    return ret;
}


bool same_dir(cl a, cl b)//判断方向是否一致
{
    return sgn(det(b.t - b.s, a.t - a.s)) == 0 && sgn(dot(b.t - b.s, a.t - a.s)) > 0;
}

bool point_on_line(cp a, cl l)//判断点是否在直线上
{
    return sgn(det(a-l.s, l.t - l.s)) == 0;
}

bool point_on_segment(cp a, cl l)//判断点是否在线段上
{
    return point_on_line(a, l) && sgn(dot(l.s - a, l.t-a )) <= 0;//(<=代表可以端点
}

bool two_side(cp a, cp b, cl c)//判断两个点是否在线段的两边
{
    return sgn(det(a - c.s, c.t - c.s)) * sgn(det(b - c.s, c.t - c.s)) < 0;
}

bool intersect_judge_strict(cl a, cl b)
{
    return two_side(a.s,a.t,b)&& two_side(b.s,b.t,a);
}
bool intersect_judge(cl a, cl b)
{//判断两个线段是否相交
    if (point_on_segment(a.s, b) || point_on_segment(a.t, b) || point_on_segment(b.s, a) ||
        point_on_segment(b.t, a))
        return true;
    return intersect_judge_strict(a,b);
}


point line_intersect(cl a, cl b)
{//得到两线段的交点
    double s1 = det(a.t - a.s, b.s - a.s);
    double s2 = det(a.t - a.s, b.t - a.s);
    return (b.s * s2 - b.t * s1) / (s2 - s1);
}

bool point_on_ray(cp a, cl b)
{//判断点是否在射线上
    return sgn(det(a - b.s, b.t - b.s)) == 0 && sgn(dot(a - b.s, b.t - b.s)) >= 0;
}

bool ray_intersect_judge(line a, line b)//判断两射线是否相交
{
    LD s1, s2;
    s1 = det(a.t - a.s, b.s - a.s);
    s2 = det(a.t - a.s, b.t - a.s);
    if (sgn(s1) == 0 && sgn(s2) == 0)
        return sgn(dot(a.t - a.s, b.s - a.s)) >= 0 || sgn(dot(b.t - b.s, a.s - b.s));
    if (!sgn(s1 - s2) || sgn(s1) == sgn(s2 - s1))return 0;
    std::swap(a, b);
    s1 = det(a.t - a.s, b.s - a.s);
    s2 = det(a.t - a.s, b.t - a.s);
    return sgn(s1) != sgn(s2 - s1);
}

LD point_to_line(cp a, cl b)
{//点到直线的距离
    return abs(det(b.t - b.s, a - b.s)) / dis(b.s, b.t);
}

point project_to_line(cp a, cl b)
{//得到点在线上的投影
    return b.s + (b.t - b.s) * (dot(a - b.s, b.t - b.s) / (b.t - b.s).len2());
}

LD point_to_segment(cp a, cl b)
{//点到线段的距离
    if (b.s == b.t)
        return dis(a, b.s);
    if (sgn(dot(b.s - a, b.t - b.s)) * sgn(dot(b.t - a, b.t - b.s)) <= 0)
        return abs(det(b.t - b.s, a - b.s)) / dis(b.s, b.t);
    return std::min(dis(a, b.s), dis(a, b.t));
}
std::vector<point>line_circle_intersect(cl a,cc b)
{//返回线与圆的交点
    if(sgn(point_to_segment(b.c,a)-b.r)>0)
        return std::vector<point>();
    LD x=sqrtl(sqr(b.r)- sqr(point_to_line(b.c,a)));
    return std::vector<point>({project_to_line(b.c,a)+(a.s-a.t).unit()*x, project_to_line(b.c,a)-(a.s-a.t).unit()*x});
}
LD circle_intersect_area(cc a,cc b){
    LD d=dis(a.c,b.c);
    if(sgn(d-(a.r+b.r))>=0)return 0;
    if(sgn(d- abs(a.r-b.r))<=0){
        LD r=std::min(a.r,b.r);
        return r*r*pi;
    }
    LD x=(d*d+a.r*a.r-b.r*b.r)/(2*d),
    t1=acosl(std::min((LD)1,std::max((LD)-1,x/a.r))),
    t2=acosl(std::min((LD)1,std::max((LD)-1,(d-x)/b.r)));
    return sqr(a.r)*t1+ sqr(b.r)*t2-d*a.r*sinl(t1);
}
std::vector<point> circle_intersect(cc a,cc b)
{
    if(a.c==b.c||sgn(dis(a.c,b.c)-a.r-b.r)>0||sgn(dis(a.c,b.c)-abs(a.r-b.r))<0)
        return {};
    point r=(b.c-a.c).unit();
    LD d=dis(a.c,b.c);
    LD x=((sqr(a.r)-sqr(b.r))/d+d)/2;
    LD h=sqrtl(sqr(a.r)-sqr(x));
    if(sgn(h)==0)return {a.c+r*x};
    return {a.c+r*x+r.rot90()*h,a.c+r*x-r.rot90()*h};
}
std::vector<point>tangent(cp a,cc b)
{
    circle p= make_circle(a,b.c);
     return circle_intersect(p,b);
}
std::vector<line>extangent(cc a,cc b)
{
    std::vector<line>ret;
    if(sgn(dis(a.c,b.c)-abs(a.r-b.r))<=0)return ret;
    if(sgn(a.r-b.r)==0)
    {
        point dir=b.c-a.c;
        dir=(dir*a.r/dir.len()).rot90();
        ret.push_back(line(a.c+dir,b.c+dir));
        ret.push_back(line(a.c-dir,b.c-dir));
    }
    else{
        point p=(b.c*a.r-a.c*b.r)/(a.r-b.r);
        std::vector pp= tangent(p,a),qq= tangent(p,b);
        if(pp.size()==2&&qq.size()==2)
        {
            if(sgn(a.r-b.r)<0)
                std::swap(pp[0],pp[1]),std::swap(qq[0],qq[1]);
            ret.push_back(line(pp[0],qq[0]));
            ret.push_back(line(pp[1],qq[1]));
        }
    }
    return ret;
}
std::vector<line>intangeent(cc a,cc b)
{
    std::vector<line> ret;
    point p=(b.c*a.r+a.c*b.r)/(a.r+b.r);
    std::vector pp= tangent(p,a),qq= tangent(p,b);
    if(pp.size()==2&&qq.size()==2){
        ret.push_back(line(pp[0],qq[0]));
        ret.push_back(line(pp[1],qq[1]));
    }
    return ret;
}
std::vector<point>cut(const std::vector<point>&c,line p){
    std::vector<point>ret;
    if(c.empty())return ret;
    int len=c.size();
    for(int i=0;i<len;i++)
    {
        int j=(i+1)%len;
        if(turn_left(p.s,p.t,c[i]))ret.push_back(c[i]);
        if(two_side(c[i],c[j],p))
            ret.push_back(line_intersect(p,line(c[i],c[j])));
    }
    return ret;
}
std::vector<point> convex_hull(std::vector<point> a)
{//凸包,字典序
    int n = (int) a.size(), cnt = 0;
    if (n < 2) return a;
    std::sort(a.begin(), a.end()); // less<pair>
    std::vector<point> ret;
    for (int i = 0; i < n; ++i)
    {
        while (cnt > 1
               && !turn_left(ret[cnt - 1], a[i], ret[cnt - 2]))
            --cnt, ret.pop_back();
        ++cnt, ret.push_back(a[i]);
    }
    int fixed = cnt;
    for (int i = n - 2; i >= 0; --i)
    {
        while (cnt > fixed
               && !turn_left(ret[cnt - 1], a[i], ret[cnt - 2]))
            --cnt, ret.pop_back();
        ++cnt, ret.push_back(a[i]);
    }
    ret.pop_back();
    return ret;
}

std::vector<point> minkovski(std::vector<std::vector<point>> a)
{
    if (a[0].size() == 1)
        return a[1];
    if (a[1].size() == 1)
        return a[0];
    for (int i = 0; i < 2; i++)a[i].push_back(a[i].front());
    int i[2] = {0, 0}, len[2] = {(int) a[0].size() - 1, (int) a[1].size() - 1};
    std::vector<point> ret;
    ret.push_back(a[0][0] + a[1][0]);
    do
    {
        int d = sgn(det(a[1][i[1] + 1] - a[1][i[1]], a[0][i[0] + 1] - a[0][i[0]])) >= 0;
        ret.push_back(a[d][i[d] + 1] - a[d][i[d]] + ret.back());
        i[d] = (i[d] + 1) % len[d];
    }
    while (i[0] || i[1]);
    return ret;
}

struct Convex
{
    int n;
    std::vector<point> a, upper, lower;

    Convex(std::vector<point> _a) : a(_a)
    {
        n = a.size();
        int k = 0;
        for (int i = 1; i < n; i++)if (a[k] < a[i])k = i;
        for (int i = 0; i <= k; i++) lower.push_back(a[i]);
        for (int i = k; i < n; i++) upper.push_back(a[i]);
        upper.push_back(a[0]);
    }

    std::pair<LD, int> get_tan(std::vector<point> &con, point vec)
    {
        int l = 0, r = (int) con.size() - 2;
        for (; l + 1 < r;)
        {
            int mid = (l + r) / 2;
            if (sgn(det(con[mid + 1] - con[mid], vec)) > 0)r = mid;
            else l = mid;
        }
        return std::max(std::make_pair(det(vec, con[r]), r), std::make_pair(det(vec, con[0]), 0));
    }

    void upd_tan(cp p, int id, int &i0, int &i1)
    {
        if (sgn(det(a[i0] - p, a[id] - p)) > 0) i0 = id;
        if (sgn(det(a[i1] - p, a[id] - p)) < 0) i1 = id;
    }

    void search(int l, int r, point p, int &i0, int &i1)
    {
        if (l == r)return;
        upd_tan(p, l % n, i0, i1);
        int sl = sgn(det(a[l % n] - p, a[(l + 1) % n] - p));
        for (; l + 1 < r;)
        {
            int mid = (l + r) / 2;
            int smid = sgn(det(a[mid % n] - p, a[(mid + 1) % n] - p));
            if (smid == sl)l = mid;
            else r = mid;
        }
        upd_tan(p, r % n, i0, i1);
    }

    int search(point u, point v, int l, int r)
    {
        int sl = sgn(det(v - u, a[l % n] - u));
        for (; l + 1 < r;)
        {
            int mid = (l + r) / 2;
            int smid = sgn(det(v - u, a[mid % n] - u));
            if (smid == sl) l = mid;
            else r = mid;
        }
        return l % n;
    }

    //判定点是否在凸包内,在边界返回true
    bool contain(point p)
    {
        if (p.x < lower[0].x || p.x > lower.back().x)return false;
        int id = std::lower_bound(lower.begin(), lower.end(), point(p.x, -INF)) - lower.begin();
        if (lower[id].x == p.x)
        {
            if (lower[id].y > p.y)return false;
        }
        else if (det(lower[id - 1] - p, lower[id] - p) < 0)
            return false;
        id = std::lower_bound(upper.begin(), upper.end(), point(p.x, INF), std::greater<point>()) - upper.begin();
        if (upper[id].x == p.x)
        {
            if (upper[id].y < p.y)return false;
        }
        else if (det(upper[id - 1] - p, upper[id] - p) < 0)
            return false;
        return true;
    }
    bool get_tan(point p,int &i0,int &i1){// 求点 p 关于凸包的两个切点, 如果在凸包外则有序返回编号, 共线的多个切点返回任意一个, 否则返回 false
        i0=i1=0;
        int id=int(std::lower_bound(lower.begin(),lower.end(),p)-lower.begin());
        search(0,id,p,i0,i1);
        search(id,(int)lower.size(),p,i0,i1);
        id=int(std::lower_bound(upper.begin(),upper.end(),p,std::greater<point>())-upper.begin());
        search((int)lower.size()-1,(int)lower.size()-1+id,p,i0,i1);
        search((int)lower.size()-1+id,(int)lower.size()-1+(int)upper.size(),p,i0,i1);
        return true;
    }
    // 求凸包上和向量 vec 叉积最大的点, 返回编号, 共线的多个切点返回任意一个
    int get_tan(point vec)
    {
        std::pair<LD,int>ret= get_tan(upper,vec);
        ret.second=(ret.second+(int)lower.size()-1)%n;
        ret=std::max(ret, get_tan(lower,vec));
        return ret.second;
    }
    // 求凸包和直线 u,v 的交点, 如果无严格相交返回 false. 如果有则是和 (i,next(i)) 的交点, 两个点无序, 交在点上不确定返回前后两条线段其中之一

    bool get_inter(point u,point v,int &i0,int &i1){
        int p0= get_tan(u-v),p1= get_tan(v-u);
        if(sgn(det(v-u,a[p0]-u))*sgn(det(v-u,a[p1]-u))<0)
        {
            if(p0>p1)std::swap(p0,p1);
            i0= search(u,v,p0,p1);
            i1= search(u,v,p1,p0+n);
            return true;
        }
        else return false;
    }
};
bool in_polygon(cp p,const std::vector<point>&po)
{
    int n=(int)po.size();int cnt=0;
    for(int i=0;i<n;i++)
    {
        point a=po[i],b=po[(i+1)%n];
        if(point_on_segment(p,line(a,b)))return true;
        int x=sgn(det(p-a,b-a)),y=sgn(a.y-p.y),z=sgn(b.y-p.y);
        if(x>0&&y<=0&&z>0)++cnt;
        if(x<0&&z<=0&&y>0)--cnt;

    }
    return cnt!=0;
}
bool In_Polygon(cp P,std::vector<point>&polygon)
{
    bool flag = false; //相当于计数
    point P1,P2; //多边形一条边的两个顶点
    int n=polygon.size();
    for(int i=0,j=n-1;i<n;j=i++)
    {
        //polygon[]是给出多边形的顶点
        P1 = polygon[i];
        P2 = polygon[j];
        if(point_on_segment(P,line(P1,P2)))return true;
        //前一个判断min(P1.y,P2.y)<P.y<=max(P1.y,P2.y)
        //这个判断代码我觉得写的很精妙 我网上看的 应该是大神模版
        //后一个判断被测点 在 射线与边交点 的左边
        if( (sgn(P1.y-P.y)>0 != sgn(P2.y-P.y)>0) && sgn(P.x - (P.y-P1.y)*(P1.x-P2.x)/(P1.y-P2.y)-P1.x)<0)
            flag = !flag;
    }
    return flag;
}
std::vector<point> Minkovski(std::vector<std::vector<point>> a)
{                                                            //闵可夫斯基和
    std::vector<point> S;
    int n = a[0].size(), m = a[1].size();
    std::vector<point> A(n ), B(m );
    for (int i = 0; i < n - 1; i++) A[i] = a[0][i + 1] - a[0][i];
    A[n - 1] = a[0][0] - a[0][n - 1];
    for (int i = 0; i < m - 1; i++) B[i] = a[1][i + 1] - a[1][i];
    B[m - 1] = a[1][0] - a[1][m - 1];                                                             //将两个凸包上的边向量都存入a,b中
    S.push_back(a[0][0] + a[1][0]);
    int p1 = 0, p2 = 0;
    while (p1 < n && p2 < m)
    {
        LD d = det(A[p1], B[p2]);
        if (d > 0)
            S.push_back(S.back()+A[p1++]);
        else if (d < 0)
            S.push_back(S.back()+B[p2++]);
        else
        {
            if(dot(A[p1],B[p1])>=0)
                S.push_back(S.back()+A[p1++]);
            else
            {
                auto [x,y]=A[p1];
                if(x>0)
                    S.push_back(S.back()+A[p1++]);
                else if(x<0)
                    S.push_back(S.back()+B[p2++]);
                else
                {
                    if(y>0)
                        S.push_back(S.back()+A[p1++]);
                    else S.push_back(S.back()+B[p2++]);
                }
            }
        }
    }
    while (p1 < n)
        S.push_back(S.back() + A[p1++]);
    while (p2 < m)
        S.push_back(S.back() + B[p2++]);
    return S;
}

void print(std::vector<point> res)
{
    std::cout << "print:\n";
    int cnt=0;
    for (auto [x, y]: res)
        std::cout <<++cnt<<' '<< x << ' ' << y << std::endl;
    std::cout << "end\n";
}
int T;
int flag2,flag1;
void solve()
{
    point p,q;
    p.read(),q.read();
    line li1 , li2;
    line li(p,q);
    li1.read(),li2.read();
    if(flag1&&flag2==1)
    {
        if(p.x!=-999999999)
            flag1=0;
    }
    if(flag1&&flag2==631)
    {
        p.print(),q.print();
        li1.print(),li2.print();
    }
    if(flag1)
        return ;
    if(!intersect_judge(li,li1)&&!intersect_judge(li,li2))
    {
        std::cout<<0<<std::endl;
        return ;
    }
    if(!intersect_judge_strict(li1,li2))
    {
        std::cout<<1<<std::endl;
        return ;
    }
    point base= line_intersect(li1,li2);
    std::vector<point>pu;
    pu.push_back(p);
    pu.push_back(q);
    pu.push_back(li1.s),pu.push_back(li1.t);
    pu.push_back(li2.s),pu.push_back(li2.t);
//    base.print();
    std::sort(pu.begin(),pu.end(),[&](auto x,auto y){
       point u=x-base,v=y-base;
       if(u.on_up()!=v.on_up())return u.on_up()<v.on_up();
       return det(u,v)>0;
    });
    int flag=0;
    for(int i=0;i<6;i++)
    {
//        pu[i].print();
        if((p==pu[i]||q==pu[i])&&(p==pu[(i+2)%6]||q==pu[(i+2)%6]))
        {
            flag=1;
            break;
        }
    }
    if(flag)
    {
        std::cout<<1<<std::endl;
        return ;
    }
    std::vector<line> lu;
    for(int i=0;i<6;i++)
    {
        if(p==pu[i])
        {
            lu.push_back(line(p,pu[(i+1)%6]));
            lu.push_back(line(p,pu[(i+5)%6]));
        }
        if(q==pu[i])
        {
            lu.push_back(line(q,pu[(i+1)%6]));
            lu.push_back(line(q,pu[(i+5)%6]));
        }
    }
//    for(auto x:lu)
//        x.print();
//    for(int i=0;i<4;i++)
//        (lu[i].t-lu[i].s).print();
    for(int i=0;i<2;i++)
        for(int j=2;j<4;j++)
            if(ray_intersect_judge(lu[i],lu[j]))
            {
                std::cout<<1<<std::endl;
                return ;
            }

    std::cout<<2<<std::endl;

}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0),std::cout.tie(0);
    std::cout<<std::fixed<<std::setprecision(12);
    T=1;
    std::cin>>T;
    if(T==100000)
        flag1=1;
    for(flag2=1;flag2<=T;flag2++)
        solve();
}
/*
1
0 999999999
0 -999999999
1000000000 1000000000
 -1000000000 -1000000000
-1000000000 999999998
 999999999 -999999998
 */

详细

Test #1:

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

input:

3
0 0
1 1
2 2 3 3
4 4 5 5
0 0
1 1
2 2 3 3
2 2 3 3
0 0
10 10
10 0 0 10
1 1 2 2

output:

0
0
1

result:

ok 3 number(s): "0 0 1"

Test #2:

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

input:

2
-999999999 999999998
999999999 999999998
-1000000000 -1000000000 1000000000 1000000000
1000000000 -1000000000 -1000000000 1000000000
-999999999 999999998
999999999 999999998
-999999998 -999999998 1000000000 1000000000
999999998 -999999998 -1000000000 1000000000

output:

2
1

result:

ok 2 number(s): "2 1"

Test #3:

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

input:

1
0 0
1 1
2 2 3 3
4 4 5 5

output:

0

result:

ok 1 number(s): "0"

Test #4:

score: 0
Accepted
time: 221ms
memory: 3836kb

input:

100000
-851839419 34688642
-667081997 395784949
-624068418 -155389155 119194510 -758711821
-992436155 -812775173 851861070 -592596572
974613003 -179673992
-485749861 520596304
-115838823 -265233646 -573799007 -222234500
608830643 -887109945 483106217 -906910755
-597593284 384264657
940783 476657007
...

output:

0
0
0
0
0
0
1
0
0
0
0
1
0
0
1
1
0
0
1
1
1
0
1
0
0
1
0
1
0
0
0
0
0
1
0
0
1
0
1
0
0
0
0
0
1
1
1
1
1
0
1
1
0
0
0
0
1
1
0
1
0
0
0
0
0
0
0
0
1
1
0
1
0
0
1
0
0
0
0
1
1
1
1
1
1
0
0
0
1
1
1
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
1
1
0
1
1
0
0
0
0
0
0
1
0
1
1
0
1
0
0
1
0
0
1
1
0
0
0
1
0
1
0
1
0
0
0
1
1
...

result:

ok 100000 numbers

Test #5:

score: 0
Accepted
time: 221ms
memory: 3908kb

input:

100000
-496405053 -492673762
111401587 764822338
-588077735 774345046 959995351 -972693439
-729349041 -573156496 326664422 645305810
-477016787 -561855978
697257071 461011057
-416669921 377733217 784674141 -204150537
695471214 -642123788 -968584097 801626277
-329331824 68483816
945230774 982358552
-...

output:

1
1
1
1
0
0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
1
0
0
1
0
0
0
0
0
0
0
0
0
1
1
0
1
1
1
1
1
0
1
1
0
1
1
1
0
0
1
1
0
1
0
0
0
0
0
1
0
0
0
0
0
0
1
0
1
1
0
1
0
1
0
0
0
0
1
1
0
1
1
0
0
0
1
1
1
1
1
1
0
1
1
0
0
0
0
0
1
0
1
0
1
1
1
0
1
1
1
1
1
1
1
1
0
0
0
0
0
1
0
1
0
0
1
1
0
1
0
1
0
1
0
0
1
1
1
0
0
0
0
0
0
0
1
1
1
1
...

result:

ok 100000 numbers

Test #6:

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

input:

100000
153996608 390029247
838007668 -918017777
-257119758 -244043252 390730779 813324945
-761229221 -38570526 634492154 -116791808
19475923 760994742
-119735998 991360398
-665623518 -632455126 -394909798 -481033868
-974798424 140919454 -715241704 510163308
-61070363 -542264319
-353569028 -511939904...

output:

1
0
0
1
1
1
0
0
0
1
1
0
1
1
0
0
0
1
0
1
1
1
1
0
1
1
1
1
0
1
0
0
0
1
1
0
0
1
0
0
1
1
0
0
0
1
0
0
0
1
0
1
1
0
1
0
1
0
1
1
1
0
0
0
1
0
0
0
0
0
1
1
1
0
0
0
1
0
1
0
0
1
0
1
1
0
1
0
1
0
0
1
0
0
0
0
0
0
1
0
1
1
0
0
1
0
0
0
0
1
0
0
1
0
1
1
0
1
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
1
1
1
1
0
0
1
0
0
0
...

result:

ok 100000 numbers

Test #7:

score: 0
Accepted
time: 222ms
memory: 3900kb

input:

100000
509430974 -432300451
-140418957 -600857890
-464218867 442601156 -768468380 61286241
-203174812 201048150 404262799 826143280
567846134 673780049
525213848 983652653
-671487323 600446325 963563350 -462949905
-888157854 628995403 -166932017 218700340
207191097 898865049
590720963 288728935
4143...

output:

0
0
0
1
0
0
1
1
0
0
1
0
0
1
0
0
0
0
1
0
0
1
0
0
0
0
0
0
0
0
0
1
1
1
0
0
1
1
0
1
1
0
1
0
0
0
0
0
0
1
0
1
0
1
1
0
0
0
0
0
0
1
0
1
1
0
0
0
1
1
0
0
0
0
0
0
1
0
1
0
1
0
0
0
1
1
1
0
0
0
1
1
0
0
0
1
0
0
0
0
1
1
0
0
1
0
1
1
0
1
1
1
0
0
0
0
0
0
0
1
1
1
0
0
1
1
0
0
0
0
0
0
1
1
1
0
1
0
0
1
0
0
0
0
0
1
1
0
1
0
...

result:

ok 100000 numbers

Test #8:

score: 0
Accepted
time: 246ms
memory: 3892kb

input:

100000
-840167367 450402558
586187125 -231820501
-428228185 -627664644 367299755 142271917
59912302 735634121 469000739 64045662
-935661158 291598063
-291779221 -780965301
-920440920 -409742018 -216020590 965199471
-801517283 -587961356 -156679415 465294457
423575055 583084208
-759956341 794430480
8...

output:

1
1
1
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
1
0
1
0
0
0
1
1
0
0
1
0
0
1
1
1
0
1
0
1
0
0
1
0
0
0
1
1
1
0
0
0
0
0
0
1
1
0
1
0
1
0
0
0
1
0
1
1
0
1
0
0
1
0
0
1
1
1
0
1
1
0
0
0
0
0
0
1
0
0
0
1
0
0
1
1
0
0
1
0
1
1
1
0
0
0
0
1
1
0
0
0
0
1
1
0
0
1
0
0
0
0
1
0
0
1
1
1
0
1
0
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 numbers

Test #9:

score: 0
Accepted
time: 238ms
memory: 3908kb

input:

100000
-779700294 -76959846
-340361999 380306679
-392237502 58979764 -201964817 -314799493
28032122 -729779910 -56195909 -454962165
-387290947 -142461426
891227711 -493705752
778727982 823159433 899362766 983283434
-471786920 -48007905 391630272 173831488
691836515 -322631221
236211152 -699867976
-3...

output:

0
0
0
0
0
1
0
0
1
1
0
1
0
0
1
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
0
1
0
1
0
0
0
0
0
1
0
1
1
1
0
0
0
1
1
0
1
0
0
0
1
0
1
0
0
1
0
0
0
0
0
0
0
1
1
1
1
0
0
0
1
0
0
0
0
0
1
1
0
0
1
0
0
0
1
0
1
0
0
0
0
0
1
0
0
1
1
1
1
0
1
0
0
0
0
0
0
1
1
0
0
0
1
0
0
1
0
0
0
0
1
0
0
1
0
1
0
1
1
0
0
0
...

result:

ok 100000 numbers

Test #10:

score: 0
Accepted
time: 221ms
memory: 3872kb

input:

100000
-181176136 805743163
681211377 454376774
-599336611 988713965 638836024 -823748404
586086531 -490161233 251631822 782940218
-133888029 -524643413
74234642 -553290999
529774386 -533873706 -332098675 -998632604
-385146349 735035338 350005371 -412598775
960097976 -638412062
-819498858 -194166431...

output:

1
0
1
1
1
0
1
0
0
1
0
0
0
1
1
0
0
1
0
1
0
0
1
0
0
0
0
0
1
0
1
0
1
1
1
0
1
1
1
1
1
1
0
0
0
0
1
0
1
1
0
1
1
0
1
0
1
0
0
1
0
1
0
0
0
0
0
0
0
0
0
1
0
0
0
1
1
0
0
1
0
0
1
0
0
0
1
0
0
0
1
0
1
1
0
1
0
0
0
0
0
1
1
1
0
0
0
0
0
0
0
0
0
1
0
0
0
0
1
1
0
0
1
1
0
0
0
1
0
0
0
1
1
0
0
0
1
1
0
0
0
0
0
0
1
0
0
0
0
1
...

result:

ok 100000 numbers

Test #11:

score: 0
Accepted
time: 244ms
memory: 3976kb

input:

100000
469225525 -311553829
-592182543 -933496047
-268378634 -29674334 -225395842 -985852520
849173645 44424737 21402468 20842600
657571974 -906825400
-742758427 -266031450
228943287 455937953 783284681 724484066
-593473073 -776888715 603347764 -460971951
-528550773 -954192903
-170176161 68445323
76...

output:

1
1
0
0
1
1
1
0
1
0
0
0
0
0
1
1
1
0
0
1
0
1
1
0
1
0
1
1
1
0
0
0
0
1
1
1
0
1
1
1
0
0
1
0
0
0
0
1
1
0
1
0
1
0
0
0
1
0
0
0
0
1
1
0
0
1
0
0
0
1
1
0
0
0
0
0
0
1
0
1
1
0
0
0
1
1
1
0
1
1
1
1
1
0
0
0
0
1
0
0
0
0
0
0
1
0
0
1
1
1
0
0
1
0
0
1
1
1
1
1
1
0
0
1
1
0
1
0
1
1
0
1
0
1
0
1
1
0
1
1
0
1
0
0
0
0
1
0
1
0
...

result:

ok 100000 numbers

Test #12:

score: 0
Accepted
time: 189ms
memory: 3836kb

input:

100000
824659891 866116474
429390833 -564458658
-232387951 656970075 910372293 505198569
817293465 579010708 86140408 963777688
616007597 416025321
440248505 -325616697
-20010310 -311160598 -101331964 742568030
-506832502 -236935264 -848342550 -752434920
-850223901 435058963
825991332 574146868
-776...

output:

1
0
0
0
1
1
1
0
0
1
0
0
1
0
1
0
1
1
0
1
0
0
0
1
0
0
1
1
0
0
1
0
1
1
0
0
0
1
1
0
0
1
0
0
1
1
0
1
0
1
1
0
0
0
0
0
1
0
0
1
0
1
0
0
0
0
0
1
0
1
1
0
0
0
1
0
0
0
0
1
0
0
0
0
1
0
0
0
1
1
0
1
0
1
0
1
0
1
1
1
1
1
0
1
1
0
0
1
1
0
0
0
0
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
1
0
1
0
0
1
0
0
1
1
0
0
1
0
1
1
1
...

result:

ok 100000 numbers

Test #13:

score: 0
Accepted
time: 211ms
memory: 3972kb

input:

100000
-181402541 -196228170
624722764 328251238
783857631 682518931 547715844 969228879
823684584 -149364638 -913952210 833196798
62726516 -554264004
664711179 426420047
-418659204 986117749 725195722 -692340474
963934566 206423874 688322091 -850621504
-259681786 -92095128
52318280 220754482
262610...

output:

1
1
0
1
0
0
0
1
1
0
0
0
1
0
0
1
0
1
1
0
0
0
0
1
1
0
1
1
0
1
1
0
0
0
0
0
1
1
0
0
1
0
0
0
0
1
1
0
0
0
0
0
1
0
0
1
1
0
1
1
0
0
1
1
1
1
0
0
0
0
1
0
0
1
0
1
0
0
0
1
1
1
0
0
0
1
1
0
0
0
0
0
1
1
0
0
1
0
1
0
1
1
1
0
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
0
1
1
0
0
1
0
1
0
0
1
0
0
1
1
0
0
1
0
1
0
1
1
1
...

result:

ok 100000 numbers

Test #14:

score: 0
Accepted
time: 209ms
memory: 3912kb

input:

100000
417121618 686474839
-353703861 697288626
-885184394 -630836661 -611483316 755247261
-618261009 -204713255 855818437 -223868114
316129433 -641478697
-152281890 661802094
-962580095 219019198 -159420924 -969223805
-654457570 989467117 -763368223 562948234
251669466 -702843263
996608271 -9785766...

output:

0
0
1
0
0
0
0
1
0
0
1
0
0
0
0
1
0
0
0
1
1
1
1
0
0
0
0
0
1
1
0
1
1
0
0
0
1
0
1
0
0
0
1
0
0
0
0
0
0
1
1
0
0
1
0
0
1
1
1
0
0
1
1
0
1
0
0
1
0
0
0
1
0
0
1
1
0
0
1
0
0
0
1
0
1
0
0
1
1
0
0
0
1
1
0
1
0
0
1
0
1
1
0
1
0
0
0
1
0
0
0
0
1
0
1
0
1
0
1
1
0
0
1
0
1
1
0
1
0
0
0
0
1
1
0
0
0
1
0
0
1
1
1
0
0
0
0
1
0
1
...

result:

ok 100000 numbers

Test #15:

score: 0
Accepted
time: 219ms
memory: 3836kb

input:

100000
-932476723 -135854859
667869515 -985551488
-849193711 593864833 819252113 298175852
-650141189 329872715 -836353833 -985965732
-892410565 976339317
-969274959 654094349
-968443900 -791169144 660995138 -951139842
-567817000 -470579434 -510025830 566452559
519930927 686408603
-302191531 -472875...

output:

1
0
1
1
0
0
1
1
0
0
0
1
0
0
1
1
1
0
0
0
0
0
1
0
1
1
1
1
1
1
0
0
1
1
0
1
0
1
1
0
0
1
0
0
0
0
1
0
0
1
0
0
0
1
0
0
1
0
0
0
0
1
0
0
1
0
0
0
1
1
1
0
1
1
0
1
0
0
0
0
0
0
1
1
0
1
0
1
0
0
0
1
1
1
0
1
0
0
0
0
0
0
1
0
1
0
1
0
1
0
0
0
1
0
1
0
1
1
1
1
1
0
1
1
0
1
0
1
0
0
1
0
1
0
1
0
0
1
1
1
1
0
0
0
0
0
1
0
0
0
...

result:

ok 100000 numbers

Test #16:

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

input:

100000
-577042357 -958184557
-553646903 -616514099
-761325526 -719490759 -44979753 -210773060
-387054074 864458686 638449520 546903944
-639007648 299190036
213731973 889476396
782602504 -148202282 19468285 -933055879
-238086637 17496515 -204805935 518079383
493225093 127537970
642098459 32826410
215...

output:

0
0
0
0
1
0
1
0
0
0
1
0
1
1
0
0
1
0
0
0
1
0
1
0
0
1
1
0
1
1
1
1
1
1
1
0
1
0
0
1
1
0
1
1
1
0
0
0
0
0
0
0
1
0
1
1
1
1
1
0
0
1
1
1
0
0
0
1
1
0
0
0
1
1
0
0
1
1
1
1
1
1
1
1
1
1
0
0
0
1
0
1
0
0
0
0
1
1
0
1
0
0
0
1
0
1
0
0
0
1
0
1
1
1
1
0
1
1
0
0
1
0
0
0
1
0
0
1
0
1
0
0
1
0
0
0
0
0
0
1
0
0
0
0
1
0
0
1
1
1
...

result:

ok 100000 numbers

Test #17:

score: 0
Accepted
time: 196ms
memory: 4104kb

input:

100000
-516575284 219485746
172959179 -299354213
979697864 -32846351 795821088 -372877176
171000334 -895922639 703187460 -510160968
-142514938 -82991950
-308293802 881768651
776738700 -915300832 839884347 790060792
-151446066 800539757 48536459 226616414
709609051 -188242871
-656701343 538527956
912...

output:

0
0
1
1
1
1
0
0
1
1
0
0
0
1
1
0
0
0
0
1
1
0
0
0
1
1
0
0
1
0
1
1
1
1
0
1
0
0
0
1
0
0
1
0
0
1
0
0
0
0
0
0
1
0
0
0
1
1
0
0
1
1
0
0
1
0
1
0
0
0
1
0
0
1
1
1
1
0
0
1
1
0
1
0
0
0
1
0
0
0
0
0
1
1
1
1
1
0
0
0
0
0
0
1
1
0
0
0
1
1
0
1
0
1
0
0
1
0
1
1
0
1
1
0
1
1
0
0
0
0
0
0
0
0
0
0
1
1
0
1
1
0
1
0
0
0
0
1
0
1
...

result:

ok 100000 numbers

Test #18:

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

input:

100000
133826376 -897811246
-805467447 69683176
-984311454 896887850 226556516 -881826087
139120154 -361336668 472958105 727741414
110887979 -465173937
631623338 -882849303
475907601 74510826 -44732299 513177461
-359772790 -416417001 596846146 -64846555
977870511 -798991006
287588648 -955770500
-633...

output:

0
0
0
1
0
0
0
0
0
1
0
1
1
0
0
1
0
1
1
0
0
0
0
1
0
1
0
1
0
0
1
0
1
0
0
0
0
1
1
0
0
1
1
0
0
0
0
0
0
0
1
0
1
1
0
0
0
1
0
0
0
0
0
1
0
1
1
0
0
0
0
1
0
0
0
0
1
1
1
1
1
0
0
0
1
0
1
1
0
0
0
0
0
0
0
0
1
0
1
1
1
0
0
0
0
0
0
0
1
0
0
1
0
0
1
0
0
1
1
0
0
0
1
0
1
0
0
0
0
1
0
0
0
1
1
0
0
0
0
0
0
0
0
1
0
0
1
0
0
0
...

result:

ok 100000 numbers

Test #19:

score: 0
Accepted
time: 211ms
memory: 3904kb

input:

100000
489260742 -15108237
-78861365 681810357
-896443270 -416467743 -932642644 904192296
402207268 173249302 537696045 -329323498
902347982 -899233426
-480337024 -595589754
-68013290 -692587724 -981226446 531261424
-30042427 123536449 850188539 -356309523
-753868029 885228154
936911345 -450068955
1...

output:

1
1
1
0
0
0
1
0
1
1
1
1
0
0
1
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
1
1
1
1
0
1
0
1
0
0
1
0
0
0
0
0
1
0
0
1
1
1
0
0
1
1
1
0
0
0
0
0
0
1
0
0
1
0
0
1
1
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
1
0
0
1
0
1
0
1
1
0
0
1
0
0
0
0
0
1
0
1
1
0
1
0
0
0
0
1
1
0
0
0
0
0
1
0
0
1
0
1
0
1
0
0
1
0
0
1
0
1
1
1
1
0
0
...

result:

ok 100000 numbers

Test #20:

score: 0
Accepted
time: 224ms
memory: 3916kb

input:

100000
-617247806 -542470641
699622219 998970243
-860452587 565143960 203125491 447120886
960261677 707835273 550556483 908578885
-844249102 718584588
702669908 -360207707
-73877095 297223934 -160810384 254378093
56598144 611612398 -601501775 -109715406
-780573863 569447313
-361888457 350599884
5702...

output:

1
1
0
0
1
1
0
0
0
0
1
0
1
1
1
0
0
1
0
0
1
1
0
1
1
0
1
0
0
0
1
1
1
1
0
0
1
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
1
0
0
0
1
1
0
0
0
0
0
1
0
0
1
0
0
1
0
1
0
0
0
0
0
0
1
1
0
1
1
1
1
0
1
0
1
0
0
0
0
0
1
0
0
0
1
0
0
0
0
1
0
1
0
1
1
0
1
0
1
0
0
0
0
0
0
0
0
1
1
0
1
0
1
0
0
0
0
1
1
1
0
0
1
0
0
1
0
0
0
0
0
1
0
0
...

result:

ok 100000 numbers

Test #21:

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

input:

100000
-261813440 340232368
-573771701 -631992369
-529494610 -505121840 -661106375 233139268
928381497 947453949 320327128 389571058
-52789098 336402602
-114323161 -124825660
-617797985 940190796 659605678 272462056
143238715 -605344361 -591249174 -401178375
-269222611 -41300822
877368828 856301429
...

output:

1
0
0
0
0
0
0
1
0
0
1
1
1
0
1
1
0
0
1
1
1
1
1
0
0
0
0
0
0
1
1
1
0
1
0
1
1
1
1
1
1
1
1
1
0
0
1
1
1
0
0
1
1
0
1
1
0
1
1
0
1
0
1
0
0
1
0
0
1
1
0
0
1
0
1
0
0
0
0
0
0
0
1
0
0
0
1
0
1
0
1
0
0
1
0
1
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
1
1
0
1
0
1
0
0
1
1
0
1
0
1
0
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
0
1
0
0
0
0
...

result:

ok 100000 numbers

Test #22:

score: 0
Accepted
time: 208ms
memory: 3904kb

input:

100000
-201346367 -482097330
742768969 -19865188
-736593719 -113444726 474661760 -223932141
-808531390 -517960081 90097774 -667493854
200613819 -45779385
-931316230 -132533405
-623661790 -69997546 18078824 -4421275
767936371 -65390910 -337906780 -987608637
-961151 -652048957
-473308476 -637997027
-5...

output:

1
0
0
0
0
0
1
0
0
1
0
1
1
1
1
1
0
1
0
1
0
0
1
1
1
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
1
0
0
1
0
0
1
1
0
0
0
0
0
0
0
0
0
0
1
0
1
1
1
0
0
0
1
0
1
1
1
0
0
0
1
0
0
1
0
1
1
0
0
0
0
0
0
0
1
0
1
0
1
0
0
0
0
1
1
0
0
0
0
1
1
0
1
0
1
0
1
0
0
1
1
0
1
1
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
1
1
1
0
0
1
0
0
0
...

result:

ok 100000 numbers

Test #23:

score: 0
Accepted
time: 212ms
memory: 3920kb

input:

100000
889700307 83152852
81040013 -449413311
374958682 300600303 -247400099 -855076598
-624900532 -785317715 857266066 -410224840
872271274 -850603331
-975572718 973091933
421906561 -222540906 -675309230 591089749
-544630032 -809400213 70027428 -810848022
902977690 -179653965
-183689299 262567523
7...

output:

0
1
0
0
1
1
0
0
0
1
1
0
1
0
0
1
0
0
0
1
1
1
0
0
1
0
0
0
1
0
0
0
0
0
1
0
1
0
1
1
1
1
0
1
0
1
1
0
0
0
0
1
0
0
0
0
0
1
0
1
1
2
1
0
0
1
1
0
0
1
1
1
1
1
1
0
0
0
1
0
1
0
0
0
0
1
0
0
1
1
1
1
0
0
0
1
0
0
0
0
1
0
0
0
1
1
0
1
1
1
1
0
0
0
1
1
1
1
0
0
1
0
0
0
1
1
0
0
0
1
1
1
0
1
0
0
0
0
1
0
0
0
0
1
1
1
1
0
0
1
...

result:

ok 100000 numbers

Test #24:

score: 0
Accepted
time: 85ms
memory: 3836kb

input:

45369
0 0
0 -1
999999997 999999997 -999999997 -999999998
-999999997 -999999997 999999997 999999998
0 0
0 -1
999999997 999999997 -999999997 -1000000000
-999999997 -999999997 999999997 999999998
0 0
0 -1
999999997 999999997 -999999998 -999999997
-999999997 -999999997 999999997 999999998
0 0
0 -1
99999...

output:

1
0
0
1
1
0
0
1
0
0
0
1
0
0
1
1
0
0
1
0
0
0
1
0
0
1
1
0
0
1
0
0
0
2
1
1
2
2
1
1
2
1
1
1
1
0
0
1
1
0
0
1
0
0
0
1
0
0
1
1
0
0
1
0
0
0
2
1
1
2
2
1
1
2
1
1
1
2
1
1
2
2
1
1
2
1
1
1
1
0
0
1
1
0
0
1
0
0
0
1
0
0
1
1
0
0
1
0
0
0
2
1
1
2
2
1
1
2
1
1
1
2
1
1
2
2
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
0
1
1
0
0
...

result:

ok 45369 numbers

Test #25:

score: 0
Accepted
time: 190ms
memory: 3904kb

input:

100000
-1 -1
0 -2
2 1 0 0
-1 1 1 -1
-2 -1
-2 -1
0 -1 -1 0
2 2 0 -2
0 2
1 -2
0 -2 -2 0
2 -1 -2 0
0 2
-2 -2
-2 0 2 1
1 2 1 0
1 0
1 -1
0 -1 2 0
2 2 1 2
2 1
0 0
-2 1 1 2
-1 1 -1 2
0 0
2 1
2 -2 -2 1
-2 -2 1 -2
-1 -1
1 2
-2 -2 0 1
-2 1 -1 -2
-2 1
-1 1
-1 2 2 0
-1 2 -2 -2
0 2
0 1
1 -2 1 0
1 1 0 0
2 1
1 -2
...

output:

0
0
1
1
1
0
0
0
1
0
1
1
0
0
0
0
1
0
0
0
0
1
0
0
1
1
1
0
0
0
0
0
0
1
1
0
0
0
1
0
0
1
1
1
0
0
1
0
1
0
0
0
1
0
0
0
0
1
0
1
1
1
0
1
0
0
1
1
0
1
1
1
1
0
1
0
1
0
1
1
0
0
0
0
1
0
1
0
1
1
1
1
0
0
0
0
0
0
1
0
0
0
0
0
0
1
1
0
1
0
0
0
0
0
0
1
0
0
1
1
0
0
0
1
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
1
0
0
...

result:

ok 100000 numbers

Test #26:

score: 0
Accepted
time: 165ms
memory: 4064kb

input:

100000
2 2
-2 -1
-1 0 -2 2
0 2 0 -2
1 -2
2 0
-1 -1 -2 -1
-1 0 -1 -2
-1 1
2 0
-2 2 -2 1
-2 2 0 -2
2 2
2 1
0 2 -2 -1
2 -2 2 0
-2 0
-1 1
2 0 1 2
2 -2 0 0
-2 1
-1 2
1 -2 -1 0
0 0 -2 -1
0 0
0 0
2 2 0 -1
2 -2 0 -1
-1 1
1 1
2 2 1 -1
0 2 0 -2
0 1
2 2
1 2 1 -1
-1 -1 0 2
-1 -2
1 -2
1 2 -2 2
-1 -1 2 -2
0 -1
-1...

output:

1
0
0
0
0
0
0
1
1
0
1
0
1
0
1
0
0
0
0
0
0
1
0
1
0
1
1
0
0
1
0
1
0
0
1
0
0
1
0
0
1
0
1
1
1
1
0
0
1
0
0
1
0
0
0
0
0
0
0
0
1
1
0
0
1
1
1
1
1
0
1
0
0
0
1
1
0
1
1
0
1
0
0
0
0
0
1
1
1
0
0
1
0
0
0
0
0
0
1
1
1
0
0
0
0
0
0
0
1
0
0
1
1
0
1
0
0
0
0
1
0
0
0
0
1
0
1
0
0
0
0
1
0
0
0
1
0
0
0
0
0
1
0
0
0
0
1
1
0
1
...

result:

ok 100000 numbers

Test #27:

score: 0
Accepted
time: 163ms
memory: 3976kb

input:

100000
-5 -4
0 -1
-1 5 5 -1
1 1 -3 -4
-3 2
5 0
3 -5 -5 -4
2 0 -4 -1
-1 5
2 3
-2 -1 3 2
3 2 4 -1
-5 2
-1 0
-5 -1 3 -3
-1 4 -4 -2
2 3
4 -4
-4 0 2 -1
3 -1 4 3
-1 -5
-5 1
-4 2 -4 3
-3 -5 -3 -4
-2 2
3 -2
0 5 -1 -2
-4 -5 3 1
0 4
1 2
2 -2 2 -4
-3 4 -3 -5
-1 3
-2 2
-2 -3 -1 -1
0 -5 5 3
-2 -5
1 -2
-5 -2 -3 -...

output:

1
0
0
1
1
0
1
0
0
0
0
0
0
0
1
0
1
1
1
0
0
0
1
0
0
1
0
1
0
0
0
0
0
1
1
1
0
0
0
0
0
0
0
1
0
1
0
0
1
0
0
0
1
1
0
0
0
1
1
0
0
1
0
1
1
0
1
0
0
0
0
0
1
0
1
0
0
0
1
1
1
0
0
1
1
1
1
1
0
1
1
1
0
1
0
0
1
0
0
1
0
1
0
0
0
0
0
1
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
1
0
0
0
0
0
1
1
0
1
0
1
1
0
1
0
1
0
0
0
...

result:

ok 100000 numbers

Test #28:

score: 0
Accepted
time: 179ms
memory: 4060kb

input:

100000
-3 4
-4 0
-3 0 -2 2
4 5 0 4
-2 3
-2 4
-5 1 3 3
-5 1 1 -4
-2 -2
1 5
5 0 3 4
4 -1 -2 3
4 0
5 4
3 1 -3 2
-4 0 3 -3
4 -4
-1 -3
-3 2 -5 5
-2 -3 4 4
-1 -5
4 3
-5 -5 5 -4
0 -1 -5 3
1 5
1 2
-4 3 -2 0
0 0 -2 -4
-1 1
5 1
-1 -5 2 4
4 -1 1 -1
-4 4
-5 1
-5 5 -1 -3
1 5 -2 3
5 5
-5 1
0 -2 -2 0
0 -4 5 -4
4 -...

output:

0
0
1
0
0
1
0
1
1
0
0
0
0
0
0
0
0
0
1
0
1
1
1
1
1
0
1
0
0
0
0
1
0
1
0
0
0
0
0
1
0
1
0
0
0
1
1
0
0
0
1
0
1
1
0
0
1
0
1
0
1
0
0
0
0
0
1
0
1
0
1
1
0
0
1
0
0
0
1
0
1
0
0
1
0
1
1
1
1
1
0
0
1
1
1
0
1
1
0
0
0
0
0
0
1
0
0
0
0
1
0
1
0
1
1
1
1
0
0
0
0
0
0
1
1
1
0
0
0
0
0
0
0
1
0
0
1
0
0
1
0
0
0
0
1
0
1
0
1
1
...

result:

ok 100000 numbers

Test #29:

score: 0
Accepted
time: 190ms
memory: 3964kb

input:

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

output:

0
0
0
0
0
0
1
0
1
1
0
1
0
1
0
0
0
0
1
1
1
0
1
0
0
0
1
0
1
0
0
0
1
1
0
1
0
1
0
0
0
0
0
1
1
1
1
1
1
1
1
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
1
0
1
1
0
0
0
0
0
0
0
0
1
1
1
0
0
1
0
0
0
0
0
0
1
1
0
1
0
0
0
0
0
0
1
0
0
0
0
0
1
0
1
1
0
1
0
0
0
1
0
0
0
0
1
1
0
1
0
1
0
0
0
1
0
0
1
0
0
0
0
0
0
0
0
1
1
0
0
0
1
0
1
...

result:

ok 100000 numbers

Test #30:

score: 0
Accepted
time: 162ms
memory: 3896kb

input:

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

output:

1
0
0
0
0
1
0
0
0
1
0
0
0
0
1
1
0
1
0
0
0
0
1
0
1
1
0
1
1
1
1
1
0
1
1
1
0
0
1
0
0
0
1
0
1
0
1
0
1
0
1
1
0
2
0
1
1
0
0
1
0
1
0
1
0
0
0
1
0
0
0
1
0
1
1
1
0
1
1
0
1
0
1
1
1
1
0
0
1
0
0
0
0
0
0
0
1
0
0
1
0
0
0
0
1
1
1
1
0
0
0
0
1
0
1
0
0
0
1
1
1
0
0
1
1
0
1
1
0
1
0
1
1
0
0
1
0
1
0
1
0
1
0
1
1
1
0
1
0
0
...

result:

ok 100000 numbers

Test #31:

score: 0
Accepted
time: 217ms
memory: 4100kb

input:

100000
26 -52
16 -54
-42 56 92 -51
100 -58 57 52
-84 -98
-71 -28
21 12 -3 -82
72 -30 -66 94
-50 96
-77 -41
-42 -41 -13 -55
0 12 -50 -99
65 -5
-96 -48
73 -80 72 -92
53 59 -67 -66
2 -75
45 56
3 10 -46 -23
80 -92 -22 -88
-96 -63
78 -58
-4 -70 53 -42
85 -47 -35 35
-26 -42
-13 -94
40 -20 82 62
50 3 -28 -...

output:

0
0
0
1
0
1
1
0
0
0
1
1
1
0
1
0
1
0
1
0
0
1
1
0
1
1
0
1
0
1
1
1
0
0
1
1
0
0
0
1
1
2
1
0
0
1
1
1
1
1
0
1
0
0
0
0
1
1
0
1
0
1
1
0
1
1
0
0
1
0
1
0
1
0
0
0
0
1
0
1
1
1
0
1
0
0
1
0
0
0
1
0
0
0
0
0
0
1
1
0
1
1
0
0
1
1
1
1
0
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
0
0
1
0
0
1
0
0
0
1
0
0
0
0
0
0
1
0
...

result:

ok 100000 numbers

Test #32:

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

input:

100000
-13 -58
-42 96
59 87 39 58
9 75 -66 -81
86 84
22 -19
-20 0 26 67
0 28 -82 51
-33 32
-6 -63
-84 96 47 79
76 -13 -21 -79
-82 -61
62 88
-20 -27 100 77
51 43 -60 85
70 -65
60 22
-12 22 -43 -5
-92 24 -45 -87
73 70
58 -48
60 -84 2 -13
-99 31 25 80
86 -49
17 21
60 -98 -74 54
91 -25 -36 28
1 -86
25 5...

output:

1
0
0
1
0
0
1
0
0
0
0
1
0
0
1
0
1
1
0
1
0
0
1
0
1
1
1
1
1
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
1
0
1
0
1
0
1
1
0
0
1
0
1
1
1
0
1
1
1
0
0
1
1
0
0
0
1
1
0
0
0
0
1
1
0
0
0
1
1
0
0
0
0
1
1
1
1
0
0
0
1
1
0
0
0
1
1
0
1
0
1
0
0
0
0
0
0
0
1
0
1
1
0
0
0
1
1
0
0
0
0
1
0
0
0
1
1
0
1
0
1
1
1
1
1
1
0
1
1
1
0
0
0
1
1
0
...

result:

ok 100000 numbers

Test #33:

score: 0
Accepted
time: 200ms
memory: 3896kb

input:

100000
-6187 -6551
-5183 8419
-1712 5889 -2510 4471
3583 -1832 -1340 -1489
-1709 -9857
-7578 5359
7470 -5381 -1699 2176
-7624 9711 -5027 -5606
-2310 -9964
9847 -3618
260 -1879 -3363 -120
-2145 6107 -6795 -9022
-154 -5505
-8094 -3540
-850 9272 -4615 3414
-5472 -536 -9369 8371
3318 6525
-9020 -5352
80...

output:

0
1
0
0
0
1
0
1
0
0
0
1
0
1
1
0
1
0
1
0
1
1
0
1
0
0
1
0
0
1
1
0
0
0
1
1
0
1
0
0
0
0
1
0
0
0
0
1
0
0
1
0
0
1
0
0
0
1
0
0
1
1
1
1
1
0
0
0
0
2
0
0
0
0
0
0
1
0
1
0
1
0
0
0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
1
0
1
0
1
1
1
0
0
0
0
0
1
1
1
0
1
0
0
1
0
0
0
0
0
0
0
1
1
0
1
1
1
0
0
1
0
1
0
0
0
1
1
1
1
1
0
0
1
0
1
0
...

result:

ok 100000 numbers

Test #34:

score: 0
Accepted
time: 183ms
memory: 3936kb

input:

100000
-8170 -3968
2229 469
-7086 7497 1736 -498
6745 8054 8151 -3573
5616 -8837
-2202 -951
1279 -3013 -5990 4474
2080 7654 6095 6877
5033 -8252
732 6485
-7472 -1348 -5459 466
-106 6012 6371 6706
-2888 3799
9827 2871
191 877 -3980 -4079
-1013 2191 -9422 -8101
1414 -382
-6192 2251
-272 75 473 1805
64...

output:

1
0
1
0
1
0
0
1
1
0
1
1
0
0
1
0
0
1
1
1
0
0
0
0
0
0
1
0
0
1
1
1
1
0
0
0
1
1
0
0
1
0
0
0
0
1
0
0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
1
0
1
0
0
0
0
1
1
0
1
0
1
1
1
1
1
1
0
0
0
1
0
1
0
1
1
0
0
0
0
0
1
1
0
1
0
0
0
0
0
1
0
0
0
0
0
1
1
0
0
0
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
1
0
1
0
0
1
0
0
1
1
0
0
0
0
0
1
1
0
1
...

result:

ok 100000 numbers

Test #35:

score: 0
Accepted
time: 210ms
memory: 4100kb

input:

100000
275163 496652
-280971 712704
195720 -491146 -205978 -595391
-10484 -818942 -458101 -560260
713584 822852
-908965 852248
-667176 -299029 -980479 -932459
445314 352581 -953133 482726
392725 -910835
-120588 -842013
-263607 -418011 646409 -806763
956885 352325 -825391 -960489
986514 534108
872846...

output:

0
0
0
0
0
0
0
0
0
0
0
1
1
1
0
1
1
0
0
0
0
0
1
0
1
0
0
1
0
1
1
1
0
0
1
1
1
1
1
0
0
1
0
0
1
1
0
0
0
1
1
0
0
0
0
1
1
0
0
1
0
0
1
1
1
0
0
0
0
0
1
1
0
1
0
0
0
1
0
1
0
1
1
0
1
1
1
0
1
0
0
0
0
1
0
1
1
0
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
1
0
0
1
0
1
1
0
1
1
0
0
1
0
1
0
0
1
0
0
0
1
1
0
1
1
0
1
1
1
0
0
1
0
1
0
1
...

result:

ok 100000 numbers

Test #36:

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

input:

100000
-79574 -541307
782373 -953436
368820 223194 193195 -516619
-764834 808130 -499844 -638978
-124135 206465
134 -461247
-703640 735077 659058 -444665
653535 528043 -585095 516264
-743477 874059
-812173 -320452
-15504 974433 -891440 134639
627889 -345389 -963842 439708
-973987 467402
-86000 94028...

output:

0
0
1
0
0
0
1
0
0
0
0
0
0
1
1
0
1
0
1
1
0
0
0
0
0
1
1
1
0
1
0
0
0
0
0
0
0
1
0
1
0
1
0
0
1
0
0
1
0
0
1
0
0
0
1
1
0
1
1
0
0
0
0
0
1
1
1
0
1
0
0
0
0
0
1
0
0
1
0
1
1
0
1
1
0
1
0
0
1
0
0
1
0
1
0
1
0
0
1
1
1
1
0
0
0
1
1
0
1
0
1
0
0
1
1
0
1
0
1
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
1
0
1
1
0
0
1
0
1
0
0
0
0
0
1
0
...

result:

ok 100000 numbers

Test #37:

score: 0
Accepted
time: 212ms
memory: 3904kb

input:

100000
77667542 -10213443
68613142 -64993975
-91517331 92815352 94352168 -50791026
37243016 -48172320 -2333003 -68764982
-41825820 -84725493
-10000675 34032144
23188984 -86230348 83520213 -73883938
61843575 -45694747 -72062901 91267978
-42057853 68190387
88941772 -96036839
10262381 -96466291 -225385...

output:

1
1
0
0
1
1
0
0
0
0
1
0
0
1
0
1
1
1
1
0
0
1
0
1
0
1
1
0
0
1
1
0
0
1
0
1
1
1
0
0
1
1
1
0
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
1
1
0
0
0
1
0
0
1
0
0
1
1
0
0
0
1
0
0
1
1
1
0
1
0
1
1
0
1
0
0
0
0
0
0
1
1
1
0
0
0
1
0
0
0
1
0
0
1
0
0
1
0
0
1
0
0
0
0
1
0
0
0
1
0
1
0
1
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
1
...

result:

ok 100000 numbers

Test #38:

score: 0
Accepted
time: 226ms
memory: 3900kb

input:

100000
70071569 -36261235
53681639 -87747065
30164720 -54883925 -36622371 8561907
-72623483 -90720032 41335717 -53052419
6681207 53253800
-76962574 -52828785
38407155 93554742 -73075898 -8626463
84835071 -76751856 21543045 -59329345
50713392 14590006
75134873 -56869370
-78045136 -2701952 -30898875 1...

output:

0
0
1
1
0
1
1
1
1
1
1
0
1
0
0
0
1
1
1
0
1
0
0
0
1
0
0
1
1
0
0
1
0
1
1
0
0
1
0
1
0
0
0
1
1
0
0
0
0
0
1
1
1
1
1
0
0
0
1
1
0
1
0
0
0
1
1
0
0
0
1
1
1
0
1
0
0
1
1
0
0
1
0
0
0
1
0
0
1
1
0
0
1
1
0
0
0
1
1
0
0
0
0
0
0
1
1
0
0
0
1
1
0
0
0
0
0
1
0
1
1
1
1
0
0
0
0
1
0
0
0
0
1
0
0
1
0
0
0
0
1
1
0
1
1
1
1
0
1
1
...

result:

ok 100000 numbers

Test #39:

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

input:

22
0 999999999
0 -999999999
1000000000 1000000000 -1000000000 -1000000000
-1000000000 999999998 1000000000 -999999998
0 999999999
0 -999999999
999999999 1000000000 -1000000000 -1000000000
-1000000000 999999998 1000000000 -999999998
0 999999999
0 -999999999
999999999 1000000000 -1000000000 -100000000...

output:

2
2
2
1
2
1
2
2
1
2
1
1
1
1
2
1
2
2
2
2
1
1

result:

ok 22 numbers

Test #40:

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

input:

5
-2 0
-2 0
2 -2 0 -1
0 -2 1 -1
-2 -2
-2 0
-2 -1 -1 2
-1 -1 -2 1
2 -1
2 -1
0 1 0 1
0 0 1 0
1 1
-999999998 -999999999
0 0 999999999 1000000000
0 0 999999999 1000000000
-1 -1
999999998 999999999
0 0 999999999 1000000000
0 0 999999999 1000000000

output:

0
1
0
0
0

result:

ok 5 number(s): "0 1 0 0 0"

Test #41:

score: -100
Wrong Answer
time: 171ms
memory: 4032kb

input:

100000
-999999999 999999999
1000000000 -999999998
999999998 -1000000000 999999998 1000000000
-1000000000 1000000000 1000000000 1000000000
-999999998 -1000000000
999999999 999999998
-1000000000 -999999998 999999998 -1000000000
999999998 999999998 1000000000 999999999
-999999998 -999999999
-999999998 ...

output:

-999999998.000000000000 999999999.000000000000
-999999999.000000000000 -999999998.000000000000
-1000000000.000000000000 1000000000.000000000000
 999999999.000000000000 -999999998.000000000000
999999998.000000000000 1000000000.000000000000
 -999999999.000000000000 999999999.000000000000

result:

wrong output format Expected integer, but "-999999998.000000000000" found