QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#533053#9227. Henry the Plumberucup-team004#AC ✓0ms3724kbC++2014.6kb2024-08-25 16:26:132024-08-25 16:26:13

Judging History

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

  • [2024-08-25 16:26:13]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3724kb
  • [2024-08-25 16:26:13]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;

template<class T>
struct Point {
    T x;
    T y;
    Point(const T &x_ = 0, const T &y_ = 0) : x(x_), y(y_) {}
    
    template<class U>
    operator Point<U>() {
        return Point<U>(U(x), U(y));
    }
    Point &operator+=(const Point &p) & {
        x += p.x;
        y += p.y;
        return *this;
    }
    Point &operator-=(const Point &p) & {
        x -= p.x;
        y -= p.y;
        return *this;
    }
    Point &operator*=(const T &v) & {
        x *= v;
        y *= v;
        return *this;
    }
    Point &operator/=(const T &v) & {
        x /= v;
        y /= v;
        return *this;
    }
    Point operator-() const {
        return Point(-x, -y);
    }
    friend Point operator+(Point a, const Point &b) {
        return a += b;
    }
    friend Point operator-(Point a, const Point &b) {
        return a -= b;
    }
    friend Point operator*(Point a, const T &b) {
        return a *= b;
    }
    friend Point operator/(Point a, const T &b) {
        return a /= b;
    }
    friend Point operator*(const T &a, Point b) {
        return b *= a;
    }
    friend bool operator==(const Point &a, const Point &b) {
        return a.x == b.x && a.y == b.y;
    }
    friend std::istream &operator>>(std::istream &is, Point &p) {
        return is >> p.x >> p.y;
    }
    friend std::ostream &operator<<(std::ostream &os, const Point &p) {
        return os << "(" << p.x << ", " << p.y << ")";
    }
};

template<class T>
struct Line {
    Point<T> a;
    Point<T> b;
    Line(const Point<T> &a_ = Point<T>(), const Point<T> &b_ = Point<T>()) : a(a_), b(b_) {}
};

template<class T>
T dot(const Point<T> &a, const Point<T> &b) {
    return a.x * b.x + a.y * b.y;
}

template<class T>
T cross(const Point<T> &a, const Point<T> &b) {
    return a.x * b.y - a.y * b.x;
}

template<class T>
T square(const Point<T> &p) {
    return dot(p, p);
}

template<class T>
double length(const Point<T> &p) {
    return std::sqrt(square(p));
}

template<class T>
double length(const Line<T> &l) {
    return length(l.a - l.b);
}

template<class T>
Point<T> normalize(const Point<T> &p) {
    return p / length(p);
}

template<class T>
bool parallel(const Line<T> &l1, const Line<T> &l2) {
    return cross(l1.b - l1.a, l2.b - l2.a) == 0;
}

template<class T>
double distance(const Point<T> &a, const Point<T> &b) {
    return length(a - b);
}

template<class T>
double distancePL(const Point<T> &p, const Line<T> &l) {
    return std::abs(cross(l.a - l.b, l.a - p)) / length(l);
}

template<class T>
double distancePS(const Point<T> &p, const Line<T> &l) {
    if (dot(p - l.a, l.b - l.a) < 0) {
        return distance(p, l.a);
    }
    if (dot(p - l.b, l.a - l.b) < 0) {
        return distance(p, l.b);
    }
    return distancePL(p, l);
}

template<class T>
Point<T> rotate(const Point<T> &a) {
    return Point(-a.y, a.x);
}

template<class T>
int sgn(const Point<T> &a) {
    return a.y > 0 || (a.y == 0 && a.x > 0) ? 1 : -1;
}

template<class T>
bool pointOnLineLeft(const Point<T> &p, const Line<T> &l) {
    return cross(l.b - l.a, p - l.a) > 0;
}

template<class T>
Point<T> lineIntersection(const Line<T> &l1, const Line<T> &l2) {
    return l1.a + (l1.b - l1.a) * (cross(l2.b - l2.a, l1.a - l2.a) / cross(l2.b - l2.a, l1.a - l1.b));
}

template<class T>
bool pointOnSegment(const Point<T> &p, const Line<T> &l) {
    return cross(p - l.a, l.b - l.a) == 0 && std::min(l.a.x, l.b.x) <= p.x && p.x <= std::max(l.a.x, l.b.x)
        && std::min(l.a.y, l.b.y) <= p.y && p.y <= std::max(l.a.y, l.b.y);
}

template<class T>
bool pointInPolygon(const Point<T> &a, const std::vector<Point<T>> &p) {
    int n = p.size();
    for (int i = 0; i < n; i++) {
        if (pointOnSegment(a, Line(p[i], p[(i + 1) % n]))) {
            return true;
        }
    }
    
    int t = 0;
    for (int i = 0; i < n; i++) {
        auto u = p[i];
        auto v = p[(i + 1) % n];
        if (u.x < a.x && v.x >= a.x && pointOnLineLeft(a, Line(v, u))) {
            t ^= 1;
        }
        if (u.x >= a.x && v.x < a.x && pointOnLineLeft(a, Line(u, v))) {
            t ^= 1;
        }
    }
    
    return t == 1;
}

// 0 : not intersect
// 1 : strictly intersect
// 2 : overlap
// 3 : intersect at endpoint
template<class T>
std::tuple<int, Point<T>, Point<T>> segmentIntersection(const Line<T> &l1, const Line<T> &l2) {
    if (std::max(l1.a.x, l1.b.x) < std::min(l2.a.x, l2.b.x)) {
        return {0, Point<T>(), Point<T>()};
    }
    if (std::min(l1.a.x, l1.b.x) > std::max(l2.a.x, l2.b.x)) {
        return {0, Point<T>(), Point<T>()};
    }
    if (std::max(l1.a.y, l1.b.y) < std::min(l2.a.y, l2.b.y)) {
        return {0, Point<T>(), Point<T>()};
    }
    if (std::min(l1.a.y, l1.b.y) > std::max(l2.a.y, l2.b.y)) {
        return {0, Point<T>(), Point<T>()};
    }
    if (cross(l1.b - l1.a, l2.b - l2.a) == 0) {
        if (cross(l1.b - l1.a, l2.a - l1.a) != 0) {
            return {0, Point<T>(), Point<T>()};
        } else {
            auto maxx1 = std::max(l1.a.x, l1.b.x);
            auto minx1 = std::min(l1.a.x, l1.b.x);
            auto maxy1 = std::max(l1.a.y, l1.b.y);
            auto miny1 = std::min(l1.a.y, l1.b.y);
            auto maxx2 = std::max(l2.a.x, l2.b.x);
            auto minx2 = std::min(l2.a.x, l2.b.x);
            auto maxy2 = std::max(l2.a.y, l2.b.y);
            auto miny2 = std::min(l2.a.y, l2.b.y);
            Point<T> p1(std::max(minx1, minx2), std::max(miny1, miny2));
            Point<T> p2(std::min(maxx1, maxx2), std::min(maxy1, maxy2));
            if (!pointOnSegment(p1, l1)) {
                std::swap(p1.y, p2.y);
            }
            if (p1 == p2) {
                return {3, p1, p2};
            } else {
                return {2, p1, p2};
            }
        }
    }
    auto cp1 = cross(l2.a - l1.a, l2.b - l1.a);
    auto cp2 = cross(l2.a - l1.b, l2.b - l1.b);
    auto cp3 = cross(l1.a - l2.a, l1.b - l2.a);
    auto cp4 = cross(l1.a - l2.b, l1.b - l2.b);
    
    if ((cp1 > 0 && cp2 > 0) || (cp1 < 0 && cp2 < 0) || (cp3 > 0 && cp4 > 0) || (cp3 < 0 && cp4 < 0)) {
        return {0, Point<T>(), Point<T>()};
    }
    
    Point p = lineIntersection(l1, l2);
    if (cp1 != 0 && cp2 != 0 && cp3 != 0 && cp4 != 0) {
        return {1, p, p};
    } else {
        return {3, p, p};
    }
}

template<class T>
double distanceSS(const Line<T> &l1, const Line<T> &l2) {
    if (std::get<0>(segmentIntersection(l1, l2)) != 0) {
        return 0.0;
    }
    return std::min({distancePS(l1.a, l2), distancePS(l1.b, l2), distancePS(l2.a, l1), distancePS(l2.b, l1)});
}

template<class T>
bool segmentInPolygon(const Line<T> &l, const std::vector<Point<T>> &p) {
    int n = p.size();
    if (!pointInPolygon(l.a, p)) {
        return false;
    }
    if (!pointInPolygon(l.b, p)) {
        return false;
    }
    for (int i = 0; i < n; i++) {
        auto u = p[i];
        auto v = p[(i + 1) % n];
        auto w = p[(i + 2) % n];
        auto [t, p1, p2] = segmentIntersection(l, Line(u, v));
        
        if (t == 1) {
            return false;
        }
        if (t == 0) {
            continue;
        }
        if (t == 2) {
            if (pointOnSegment(v, l) && v != l.a && v != l.b) {
                if (cross(v - u, w - v) > 0) {
                    return false;
                }
            }
        } else {
            if (p1 != u && p1 != v) {
                if (pointOnLineLeft(l.a, Line(v, u))
                    || pointOnLineLeft(l.b, Line(v, u))) {
                    return false;
                }
            } else if (p1 == v) {
                if (l.a == v) {
                    if (pointOnLineLeft(u, l)) {
                        if (pointOnLineLeft(w, l)
                            && pointOnLineLeft(w, Line(u, v))) {
                            return false;
                        }
                    } else {
                        if (pointOnLineLeft(w, l)
                            || pointOnLineLeft(w, Line(u, v))) {
                            return false;
                        }
                    }
                } else if (l.b == v) {
                    if (pointOnLineLeft(u, Line(l.b, l.a))) {
                        if (pointOnLineLeft(w, Line(l.b, l.a))
                            && pointOnLineLeft(w, Line(u, v))) {
                            return false;
                        }
                    } else {
                        if (pointOnLineLeft(w, Line(l.b, l.a))
                            || pointOnLineLeft(w, Line(u, v))) {
                            return false;
                        }
                    }
                } else {
                    if (pointOnLineLeft(u, l)) {
                        if (pointOnLineLeft(w, Line(l.b, l.a))
                            || pointOnLineLeft(w, Line(u, v))) {
                            return false;
                        }
                    } else {
                        if (pointOnLineLeft(w, l)
                            || pointOnLineLeft(w, Line(u, v))) {
                            return false;
                        }
                    }
                }
            }
        }
    }
    return true;
}

template<class T>
std::vector<Point<T>> hp(std::vector<Line<T>> lines) {
    std::sort(lines.begin(), lines.end(), [&](auto l1, auto l2) {
        auto d1 = l1.b - l1.a;
        auto d2 = l2.b - l2.a;
        
        if (sgn(d1) != sgn(d2)) {
            return sgn(d1) == 1;
        }
        
        return cross(d1, d2) > 0;
    });
    
    std::deque<Line<T>> ls;
    std::deque<Point<T>> ps;
    for (auto l : lines) {
        if (ls.empty()) {
            ls.push_back(l);
            continue;
        }
        
        while (!ps.empty() && !pointOnLineLeft(ps.back(), l)) {
            ps.pop_back();
            ls.pop_back();
        }
        
        while (!ps.empty() && !pointOnLineLeft(ps[0], l)) {
            ps.pop_front();
            ls.pop_front();
        }
        
        if (cross(l.b - l.a, ls.back().b - ls.back().a) == 0) {
            if (dot(l.b - l.a, ls.back().b - ls.back().a) > 0) {
                
                if (!pointOnLineLeft(ls.back().a, l)) {
                    assert(ls.size() == 1);
                    ls[0] = l;
                }
                continue;
            }
            return {};
        }
        
        ps.push_back(lineIntersection(ls.back(), l));
        ls.push_back(l);
    }
    
    while (!ps.empty() && !pointOnLineLeft(ps.back(), ls[0])) {
        ps.pop_back();
        ls.pop_back();
    }
    if (ls.size() <= 2) {
        return {};
    }
    ps.push_back(lineIntersection(ls[0], ls.back()));
    
    return std::vector(ps.begin(), ps.end());
}
template<class T>
struct Frac {
    T num;
    T den;
    Frac(T num_, T den_) : num(num_), den(den_) {
        if (den < 0) {
            den = -den;
            num = -num;
        }
    }
    Frac() : Frac(0, 1) {}
    Frac(T num_) : Frac(num_, 1) {}
    explicit operator double() const {
        return 1. * num / den;
    }
    Frac &operator+=(const Frac &rhs) {
        num = num * rhs.den + rhs.num * den;
        den *= rhs.den;
        return *this;
    }
    Frac &operator-=(const Frac &rhs) {
        num = num * rhs.den - rhs.num * den;
        den *= rhs.den;
        return *this;
    }
    Frac &operator*=(const Frac &rhs) {
        num *= rhs.num;
        den *= rhs.den;
        return *this;
    }
    Frac &operator/=(const Frac &rhs) {
        num *= rhs.den;
        den *= rhs.num;
        if (den < 0) {
            num = -num;
            den = -den;
        }
        return *this;
    }
    friend Frac operator+(Frac lhs, const Frac &rhs) {
        return lhs += rhs;
    }
    friend Frac operator-(Frac lhs, const Frac &rhs) {
        return lhs -= rhs;
    }
    friend Frac operator*(Frac lhs, const Frac &rhs) {
        return lhs *= rhs;
    }
    friend Frac operator/(Frac lhs, const Frac &rhs) {
        return lhs /= rhs;
    }
    friend Frac operator-(const Frac &a) {
        return Frac(-a.num, a.den);
    }
    friend bool operator==(const Frac &lhs, const Frac &rhs) {
        return lhs.num * rhs.den == rhs.num * lhs.den;
    }
    friend bool operator!=(const Frac &lhs, const Frac &rhs) {
        return lhs.num * rhs.den != rhs.num * lhs.den;
    }
    friend bool operator<(const Frac &lhs, const Frac &rhs) {
        return lhs.num * rhs.den < rhs.num * lhs.den;
    }
    friend bool operator>(const Frac &lhs, const Frac &rhs) {
        return lhs.num * rhs.den > rhs.num * lhs.den;
    }
    friend bool operator<=(const Frac &lhs, const Frac &rhs) {
        return lhs.num * rhs.den <= rhs.num * lhs.den;
    }
    friend bool operator>=(const Frac &lhs, const Frac &rhs) {
        return lhs.num * rhs.den >= rhs.num * lhs.den;
    }
    friend std::ostream &operator<<(std::ostream &os, Frac x) {
        T g = std::gcd(x.num, x.den);
        if (x.den == g) {
            return os << x.num / g;
        } else {
            return os << x.num / g << "/" << x.den / g;
        }
    }
};
using F = Frac<i64>;
using P = Point<F>;
void solve() {
    P p1, v1, p2, v2;
    i64 x1, y1, z1, x2, y2, z2;
    i64 vx1, vy1, vx2, vy2;
    std::cin >> x1 >> y1 >> z1 >> vx1 >> vy1;
    std::cin >> x2 >> y2 >> z2 >> vx2 >> vy2;
    p1 = P(x1, y1);
    v1 = P(vx1, vy1);
    p2 = P(x2, y2);
    v2 = P(vx2, vy2);
    
    Line l1(p1, p1 + rotate(v1));
    Line l2(p2, p2 + rotate(v2));
    
    if (cross(l1.b - l1.a, l2.b - l2.a) == 0) {
        if (cross(l1.b - l1.a, l2.a - l1.a) == 0) {
            std::cout << 2 << "\n";
        } else {
            std::cout << 4 << "\n";
        }
        return;
    }
    
    if (p1 == p2) {
        std::cout << 2 << "\n";
        return;
    }
    
    Point o = lineIntersection(l1, l2);
    
    if (o == p1 || o == p2) {
        if (z1 == z2) {
            std::cout << 4 << "\n";
        } else {
            std::cout << 3 << "\n";
        }
        return;
    }
    
    Point d1 = o - p1;
    Point d2 = o - p2;
    
    if ((z1 + z2) * (z1 + z2) - 4 * (z1 * z2 + dot(d1, d2)) >= 0) {
        std::cout << 3 << "\n";
    } else {
        std::cout << 4 << "\n";
    }
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int t;
    std::cin >> t;
    
    while (t--) {
        solve();
    }
    
    return 0;
}

详细

Test #1:

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

input:

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

output:

4
3

result:

ok 2 number(s): "4 3"

Test #2:

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

input:

100
-13 -5 -7
-19 19
-19 -13 0
-7 15
-20 20 19
-17 18
20 -20 -1
18 -19
-18 15 -14
-19 18
19 -20 6
20 -19
-12 9 1
7 -16
-13 -14 -8
8 -13
-19 16 9
20 -19
19 -18 -11
19 -18
19 20 -8
12 20
-11 -9 18
-19 -18
8 11 -13
12 -18
18 13 8
4 -18
-16 20 17
-19 18
20 -18 -3
20 -19
-17 -20 -5
-18 -19
19 16 15
19 20...

output:

4
4
4
4
4
4
3
4
4
4
3
4
4
3
3
4
3
4
4
4
4
4
4
4
4
4
4
4
3
3
3
4
4
4
4
4
4
4
4
4
4
4
4
4
3
4
4
4
4
4
3
4
3
4
4
4
3
4
4
4
4
4
4
4
3
4
3
4
4
4
4
4
4
4
4
4
4
4
4
3
4
4
4
4
4
4
4
3
3
4
3
4
4
4
4
4
4
4
4
4

result:

ok 100 numbers

Test #3:

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

input:

100
20 -9 -19
9 13
-12 14 -18
-17 12
2 -3 -2
2 -19
-8 9 -15
-19 3
-16 -16 -18
2 15
19 17 -6
-10 11
14 -20 -6
-19 7
-17 -8 -1
-7 -15
7 -15 3
2 13
-15 -9 11
15 2
-17 20 13
11 -8
-12 18 16
-18 -17
-17 15 -2
-20 1
8 -6 0
-16 -19
-5 -14 16
-17 10
-7 -16 17
-10 -13
1 1 -13
17 11
-3 -3 -18
4 -17
19 -6 -17
...

output:

3
4
4
4
3
3
4
3
3
4
4
3
4
4
3
3
4
3
4
4
4
4
3
4
3
4
4
3
3
4
4
4
3
4
3
3
4
3
3
4
3
4
3
4
3
4
3
4
4
3
3
4
3
3
4
3
3
4
4
3
3
4
4
3
4
3
3
4
3
3
3
4
3
4
3
4
3
4
3
4
4
3
3
4
3
4
4
4
4
3
3
3
3
4
3
3
4
4
4
4

result:

ok 100 numbers

Test #4:

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

input:

100
10 -9 -13
8 -7
-3 3 -15
-5 11
-14 -20 -17
13 -13
3 20 16
-20 8
-2 -15 -20
8 20
20 -10 15
12 6
4 2 20
14 14
-13 6 -20
-10 20
-18 -15 19
10 9
4 18 -11
-16 -15
20 -11 6
15 -10
-17 -19 -6
-6 8
-19 -19 -18
-11 -9
-6 4 18
11 -5
2 -18 20
0 -12
-10 -18 -17
20 -20
19 19 17
2 -11
-20 2 -16
-19 13
-6 6 -5
...

output:

4
3
4
3
4
4
3
3
3
4
4
3
3
3
4
4
3
3
3
4
4
4
3
4
3
3
3
3
4
4
3
4
4
3
4
3
3
4
4
3
3
3
4
4
3
4
4
4
4
4
3
4
3
4
4
4
3
4
4
3
4
4
3
3
3
4
3
3
3
3
4
4
4
4
3
4
4
3
4
3
4
3
3
3
4
4
3
4
3
4
4
3
4
3
4
4
3
3
4
4

result:

ok 100 numbers

Test #5:

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

input:

100
4 -19 -4
4 18
-15 20 -15
-16 18
-11 -10 -13
-7 14
20 -17 0
6 -20
-12 18 -8
3 -14
20 16 17
10 17
0 19 -17
-11 6
18 -19 -7
13 -13
-17 17 -17
-5 -1
17 -13 19
-10 -12
9 -3 -19
-12 -2
-16 11 13
12 -8
17 12 11
-1 20
13 -14 -5
-4 16
-20 8 -16
16 -3
9 -3 -6
14 -12
16 4 9
-16 -10
-15 -3 -17
-20 -2
20 2 1...

output:

4
4
3
4
3
4
4
4
4
4
3
4
3
4
3
3
4
3
3
4
3
4
3
3
4
4
4
4
4
3
3
4
3
4
3
4
4
4
4
4
3
4
4
4
3
4
4
4
4
4
4
4
4
3
4
4
4
4
4
3
3
3
4
4
4
4
4
3
3
4
3
4
4
4
4
3
4
4
3
4
3
4
3
4
4
4
4
4
4
3
4
3
4
4
4
4
3
4
4
4

result:

ok 100 numbers

Test #6:

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

input:

100
-1 -13 -13
-14 -8
-1 -3 15
6 -14
19 -1 -16
-20 -14
-16 12 18
20 17
-19 17 -6
16 13
15 -8 18
16 10
17 20 0
0 -13
-19 -19 15
-14 -14
-11 -16 17
17 18
0 2 -10
20 -5
-8 -16 0
3 12
-19 0 -3
1 -14
-18 3 -12
-14 -15
20 1 17
20 -4
-20 6 20
20 -7
20 1 -9
-13 -4
2 17 -18
11 13
8 16 14
-12 16
-11 12 -20
0 ...

output:

3
4
4
4
3
4
4
4
3
4
4
4
3
4
3
4
3
4
3
3
4
4
3
3
3
4
4
4
3
3
4
4
4
3
4
4
4
4
3
3
4
4
4
4
4
4
3
4
4
3
3
3
4
3
3
4
4
4
3
4
4
3
3
3
3
4
4
4
4
3
3
3
4
4
3
4
3
3
4
3
3
4
3
4
4
3
3
3
4
4
3
3
4
3
3
3
3
3
4
3

result:

ok 100 numbers

Test #7:

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

input:

100
-16 0 17
16 16
16 -12 -16
14 12
19 -13 -20
-16 -8
-14 20 14
-6 -20
6 -19 12
18 -2
7 20 -19
3 -20
19 -5 12
-16 -12
-9 -11 0
19 4
11 -20 12
14 -14
-19 16 1
-12 -1
-8 -14 11
-15 2
9 -11 18
4 20
-14 3 -16
-20 -4
11 -16 7
-10 -11
20 16 -19
-10 8
-20 0 13
-17 -8
20 -17 2
14 -2
-17 13 7
-8 -11
-8 -6 -2...

output:

4
3
3
4
4
3
3
4
3
3
3
4
3
4
4
4
4
4
4
4
4
4
4
4
4
3
4
4
4
4
4
3
4
4
3
4
3
4
4
4
4
4
4
3
4
3
4
4
4
3
3
3
4
4
4
3
4
4
4
3
4
3
4
4
4
4
4
4
3
3
3
4
3
4
4
4
3
4
4
3
3
4
3
4
3
4
4
3
4
3
4
3
4
3
4
3
3
4
3
4

result:

ok 100 numbers

Test #8:

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

input:

1
1 -1 1
1 1
1 1 2
-1 1

output:

3

result:

ok 1 number(s): "3"

Test #9:

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

input:

100
20 19 -6
18 19
-19 -20 14
19 20
-1 19 -19
6 18
12 -20 19
18 19
4 0 -18
-19 10
-13 12 7
-8 11
-19 -18 -9
-19 -20
18 20 11
18 19
-19 19 8
18 -19
18 -19 -12
-19 20
11 12 9
-15 -2
-12 -12 -4
3 11
-19 9 -10
-18 3
-3 -19 4
20 11
-19 -20 10
-20 -19
17 20 -10
19 18
-17 -20 14
19 20
17 20 -6
-18 -19
9 -1...

output:

4
4
4
4
4
4
3
4
4
3
4
4
4
4
3
4
4
3
4
4
4
4
3
4
4
4
4
3
4
4
3
4
4
3
3
4
4
4
4
4
4
4
4
4
4
3
4
4
3
4
3
4
4
4
4
3
3
4
4
4
3
3
4
4
3
4
3
3
4
3
4
3
4
4
4
4
4
4
4
3
4
4
3
4
4
3
4
4
4
4
4
4
4
4
4
3
4
4
4
4

result:

ok 100 numbers

Test #10:

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

input:

100
13 -13 12
5 12
12 20 14
-14 -8
18 -17 -5
-1 -17
-10 9 9
-10 18
13 -17 -1
19 -18
11 1 -2
-17 -18
16 19 -17
-8 6
-14 -1 16
-18 6
4 -14 18
-10 14
13 3 12
-1 -14
-20 1 -11
12 15
20 4 -20
-7 -17
8 -19 1
-9 -10
-19 8 -4
-17 18
6 -14 -12
-12 -5
-12 6 19
-18 -11
-16 -16 -10
15 16
12 18 -9
-17 16
-18 5 -...

output:

4
4
4
4
4
4
4
4
4
4
4
4
4
3
3
3
3
4
3
4
3
3
4
4
4
4
4
4
3
3
3
3
3
3
3
3
4
3
4
3
4
4
4
4
4
3
4
3
3
4
4
3
3
3
3
3
4
3
3
3
3
3
3
3
3
3
3
4
4
4
4
3
4
3
4
4
4
4
3
4
4
3
3
3
3
4
4
4
4
3
4
3
4
4
3
4
4
4
4
4

result:

ok 100 numbers

Test #11:

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

input:

73
14 -7 7
1 10
-16 -4 11
1 10
-14 -13 -16
1 -8
-6 -12 -10
-2 16
-5 -10 -12
0 -13
15 -10 0
0 -2
19 20 19
17 -9
-14 -20 -15
-20 6
3 19 4
-16 -1
5 -13 11
-16 -1
-19 -20 -17
0 11
-19 -20 -10
2 -3
-9 -15 -18
1 -13
17 -13 -11
1 -13
10 -20 17
8 -1
15 20 1
16 -2
-20 -18 8
0 -11
12 -18 17
0 -10
-4 0 10
9 0
...

output:

2
2
2
4
2
2
2
2
2
2
2
2
2
4
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
3
2
2
2
2
2
4
2
2
2
2
2
2
4
3
4
2
2
2
2
2
4
3
2
2
2
4
2
2
2
2
2
4
2
2
3
2
2

result:

ok 73 numbers

Test #12:

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

input:

100
-20 -20 10
-1 1
20 20 10
-1 6
15 -19 12
-17 20
-18 20 10
17 15
7 -19 0
-16 13
18 17 -10
11 15
17 13 9
-16 15
-6 -13 14
-13 -20
-19 2 13
-8 13
20 -13 -12
-19 -8
-20 20 4
-11 -11
20 -20 4
10 -10
-12 3 0
12 -17
-14 20 17
12 17
6 -19 7
-11 -20
14 8 -6
17 -13
-12 10 -2
19 20
15 -15 -9
-20 3
4 19 -19
...

output:

4
3
4
3
3
4
4
3
3
4
4
4
3
4
3
4
3
4
4
4
4
3
4
4
4
4
3
4
4
4
3
4
4
3
3
4
3
3
3
4
4
3
4
4
3
4
4
4
4
3
3
3
4
4
4
4
4
4
4
4
4
4
4
3
4
3
4
4
4
4
4
4
4
3
4
4
4
4
4
4
3
4
4
4
4
3
3
4
4
3
4
3
3
4
4
4
3
4
4
3

result:

ok 100 numbers

Test #13:

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

input:

100
3 -20 5
19 -11
18 2 18
17 7
18 -6 -20
20 19
-19 -9 20
13 -6
-15 -13 12
-13 1
20 -1 -5
-9 20
-16 -18 -11
16 3
15 18 2
17 -14
-6 -20 15
17 7
9 2 2
19 -11
8 19 2
20 19
4 -19 4
18 -19
12 -19 19
-12 -5
-10 20 2
13 -16
-8 0 20
13 14
17 12 11
16 -13
6 -19 9
1 13
-18 19 -14
-19 -14
-18 -20 -19
-8 19
5 1...

output:

4
4
4
4
4
4
3
3
3
3
3
3
4
4
3
4
4
4
4
4
3
3
4
3
4
4
4
3
3
3
4
4
4
3
4
4
3
3
4
3
4
4
4
3
4
4
3
3
3
4
3
3
4
4
3
4
3
4
4
4
3
4
4
3
3
3
3
3
4
4
4
4
4
3
3
4
4
3
4
4
3
3
3
3
3
3
4
3
3
3
3
3
3
4
4
3
4
3
3
3

result:

ok 100 numbers

Test #14:

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

input:

95
12 1 -16
0 15
0 -9 -5
0 -14
15 -2 7
-18 6
4 -14 -18
-2 15
-5 15 -13
-19 0
-3 6 -10
17 0
20 -16 20
-2 11
-17 -6 -15
-20 20
-5 -17 19
16 -19
5 18 18
20 8
-8 -7 -8
13 0
-14 2 5
-2 0
14 0 9
0 5
20 3 13
0 -7
-9 8 20
-18 18
7 19 12
20 -19
12 5 -8
-18 0
11 -6 -3
14 0
13 9 9
16 0
-19 -7 -11
10 12
-2 1 -1...

output:

4
3
4
4
3
4
4
4
4
4
4
4
4
4
4
4
4
3
3
4
4
4
4
4
4
4
4
4
3
3
4
4
3
4
4
4
4
4
3
3
4
4
3
4
4
4
4
4
4
4
4
4
4
4
2
4
4
3
4
4
4
3
3
3
4
4
4
4
4
4
4
4
3
4
4
4
4
3
3
4
4
4
4
4
4
3
4
3
3
4
4
3
4
4
4

result:

ok 95 numbers

Test #15:

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

input:

100
18 18 -7
-19 -18
16 0 -6
-17 18
-17 7 9
-16 -15
6 -19 4
-13 20
-20 -20 -20
-13 2
16 20 20
-3 -7
-19 19 -6
-18 17
15 -17 -7
-17 -16
-15 15 17
-14 -11
18 -8 0
16 -15
15 20 -20
-15 -12
-19 -20 20
6 -15
20 -19 -20
-10 -6
-20 17 20
14 -10
-20 20 20
10 -16
20 -20 -19
5 8
-16 -20 20
-6 -14
20 20 -20
13...

output:

4
3
3
3
4
3
3
3
3
3
4
3
3
4
3
3
3
3
4
4
3
4
3
3
3
3
3
4
3
4
4
3
4
3
4
4
3
4
4
3
3
4
3
3
3
4
4
4
4
3
3
4
3
4
3
3
4
3
4
4
3
3
4
4
4
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
4
3
4
4
4
3
3
4
3
3
4
3
3
4
3
3
4
3
3

result:

ok 100 numbers

Test #16:

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

input:

100
17 19 -19
-6 20
-5 -14 14
-15 -15
19 16 -20
-14 -19
-20 -15 16
-19 -19
-2 -17 4
15 -19
-6 -10 -11
6 -12
15 -14 -17
12 9
-10 12 3
-17 -19
-7 20 -8
5 11
1 -14 16
20 10
16 -14 -12
-16 -20
-15 1 1
-18 -8
-17 -1 -6
18 0
2 -17 -2
17 15
1 -20 -16
-16 0
-8 19 18
10 -10
14 19 -20
-2 16
-20 -13 16
-9 4
-1...

output:

4
4
4
3
4
4
4
4
3
4
4
3
3
3
4
4
4
4
4
3
3
3
4
3
3
3
4
4
4
4
4
3
3
4
3
3
3
4
4
4
4
3
4
2
4
4
3
4
4
3
4
4
3
4
3
3
4
3
3
4
3
3
4
4
3
4
3
3
4
3
3
4
3
4
4
4
3
4
4
4
4
3
4
4
3
4
4
3
3
3
3
3
3
4
3
3
4
4
4
4

result:

ok 100 numbers

Test #17:

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

input:

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

output:

4
3

result:

ok 2 number(s): "4 3"

Test #18:

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

input:

100
-7 20 16
-9 16
20 -5 -13
-16 -14
-14 -4 17
9 11
-1 14 -7
-4 -7
8 -3 -3
-13 -2
-17 -8 -1
15 1
-11 3 -20
0 -10
0 -19 13
19 4
4 17 1
-5 9
4 -19 1
18 -13
-19 5 -19
15 -10
-8 -20 19
9 18
20 13 20
4 -18
-20 -8 -18
-16 -19
20 -19 -9
-10 17
-13 3 5
7 -20
7 13 -13
-3 -6
-9 -15 17
9 -18
2 14 -19
-12 6
18 ...

output:

3
4
4
3
4
3
4
4
4
3
4
3
4
4
3
3
3
3
4
4
4
3
4
3
3
4
4
3
4
4
4
4
4
4
3
4
4
4
4
3
4
4
4
4
4
4
4
3
3
4
3
4
4
3
4
3
4
3
3
4
4
3
3
3
3
4
4
3
4
3
4
3
4
4
3
4
4
4
3
4
4
4
4
4
4
4
4
3
4
3
4
4
4
3
4
3
4
4
4
3

result:

ok 100 numbers

Test #19:

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

input:

100
4 16 -20
-11 -1
14 -20 19
5 18
-18 11 7
2 -19
-14 -10 -13
1 8
-8 -12 11
8 -17
12 17 6
-20 8
-7 2 13
12 0
-13 2 -13
-9 17
-19 19 12
6 17
0 -19 -11
15 -16
19 -17 19
-11 3
-20 2 -20
7 17
8 -13 15
-2 15
-18 0 2
-4 16
-1 -19 -1
15 -17
-15 -18 5
3 10
3 7 -15
-1 -19
-6 -13 -17
2 -10
1 -17 16
-17 -10
-1...

output:

3
4
3
3
4
3
4
3
4
3
4
4
4
4
4
4
4
4
4
4
4
4
3
4
4
4
4
4
3
3
4
3
3
4
3
4
4
4
4
4
3
4
3
4
3
4
4
4
4
4
4
4
3
4
4
4
3
4
4
4
3
3
4
4
4
3
3
4
4
4
4
3
4
4
4
4
3
4
4
3
4
3
4
4
3
4
4
4
4
4
3
4
4
4
4
4
4
4
3
3

result:

ok 100 numbers

Test #20:

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

input:

100
15 -15 17
-12 17
19 19 -17
-12 -17
-16 -3 7
13 -16
20 8 -3
-15 -11
8 11 7
20 19
14 11 5
19 -18
7 19 11
17 -11
0 8 13
1 -12
-20 -20 2
16 2
20 20 2
-2 16
-7 -11 -6
19 -20
-9 11 15
-7 -13
19 8 -7
-12 -1
8 15 -9
11 17
9 -16 20
16 -15
17 -11 15
8 5
-19 1 -18
-11 19
3 16 -5
7 17
20 -20 17
-16 -6
-20 2...

output:

4
4
3
4
3
3
4
4
4
3
3
4
4
3
4
4
4
3
3
4
4
4
4
3
3
4
3
3
4
4
4
3
3
3
3
3
3
3
3
3
4
3
3
3
4
3
3
3
3
3
3
3
3
4
4
3
4
3
3
3
4
3
3
4
3
3
3
3
4
3
4
3
3
3
3
3
3
4
3
3
3
3
3
3
3
3
4
4
3
4
4
3
3
4
4
3
3
3
3
3

result:

ok 100 numbers

Test #21:

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

input:

100
19 15 -13
-6 -14
8 8 17
7 -3
12 20 -16
0 -18
2 11 17
-20 0
12 -20 -2
11 2
-13 6 1
-18 -7
-13 11 18
-3 -19
-15 -1 -17
5 13
14 -14 -14
-4 20
-1 11 -5
7 -12
14 19 -11
16 9
-10 -13 16
4 18
20 19 0
-5 1
-7 -17 1
-12 -4
13 -9 20
-16 17
-20 12 -5
5 9
19 6 -18
-12 12
-11 -12 12
-2 -18
17 4 -18
-7 4
17 4...

output:

3
3
4
4
4
4
4
3
3
2
4
4
3
4
4
3
4
3
3
4
4
3
4
3
3
4
4
4
3
3
3
4
3
3
4
4
3
4
4
3
4
3
4
3
4
4
4
4
3
4
3
4
4
4
3
3
3
4
3
3
4
4
3
4
3
4
4
3
4
4
4
4
3
3
4
3
4
3
3
3
4
4
4
3
3
3
4
4
3
3
3
4
4
4
4
4
3
4
3
4

result:

ok 100 numbers

Test #22:

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

input:

100
20 -13 14
3 20
-16 12 -16
17 -11
20 -14 -2
10 14
-19 -6 -4
18 16
2 -14 2
8 19
7 19 -16
-11 17
17 -8 17
-10 -18
-9 -11 -19
-12 4
9 -18 -9
-11 16
-15 -16 0
-19 10
20 -8 -16
3 -13
-20 13 13
12 -20
-12 20 -2
16 11
16 -14 -12
1 5
-8 -17 3
-16 -10
8 2 -20
2 -18
-14 -19 8
-20 13
-17 16 -19
10 4
12 -10 ...

output:

4
4
4
3
4
4
3
4
3
4
3
4
4
3
3
4
3
3
4
4
3
3
4
3
4
3
4
3
3
4
3
3
3
4
4
4
3
4
4
3
3
4
4
3
3
4
4
4
3
3
3
4
4
4
4
4
3
3
4
4
4
4
3
4
4
4
4
4
4
4
3
4
3
4
4
4
4
3
4
3
3
4
3
4
3
3
4
4
3
4
4
4
3
4
4
3
4
3
3
4

result:

ok 100 numbers

Test #23:

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

input:

100
13 -13 -18
-17 9
-3 2 14
12 18
10 3 -19
-13 16
19 -10 9
-2 7
-17 8 -14
-16 1
-1 10 17
-5 -15
-1 -13 3
12 0
-12 15 -14
-7 16
-2 0 -2
-13 11
8 -14 20
15 2
15 5 -4
7 -11
4 14 14
-18 -3
-15 -10 20
11 6
-10 3 -20
-18 15
-14 14 -4
4 13
2 2 -16
15 1
1 20 19
3 7
6 -16 -20
-10 2
-1 -20 -14
-14 -19
1 11 2...

output:

3
4
3
4
4
3
3
3
3
3
3
4
3
2
4
3
3
4
4
4
4
3
4
4
3
4
4
4
4
4
4
4
4
4
4
3
4
4
4
3
4
4
4
3
4
3
4
3
4
3
4
3
3
3
3
3
3
3
4
4
4
4
3
4
4
4
4
3
3
3
3
3
4
4
4
3
3
4
3
4
3
3
4
4
4
4
3
4
3
3
4
3
4
3
4
3
4
4
3
4

result:

ok 100 numbers

Test #24:

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

input:

100
-4 18 5
14 14
17 0 13
19 -3
19 16 16
18 -16
-20 -13 -14
-13 -16
-5 2 -10
12 -6
-10 7 9
-19 -2
19 -20 8
-20 -9
-16 -4 -6
-8 0
13 -19 -16
19 9
0 19 -15
-9 12
-14 14 6
-15 17
-8 -19 -1
1 17
10 -11 -17
14 16
3 -15 12
18 -2
4 -12 -5
-18 12
-19 3 13
-9 18
2 19 -16
-18 10
20 -19 20
17 -9
18 13 -19
12 -...

output:

4
3
3
4
3
4
3
4
4
4
4
4
4
3
4
3
3
4
3
3
3
4
4
3
4
4
4
4
4
3
4
3
4
3
3
4
4
4
4
3
3
3
3
4
4
4
3
3
3
4
3
4
3
4
4
3
4
4
4
4
3
3
3
4
4
4
4
3
3
3
3
4
3
4
4
3
4
3
4
4
3
4
4
3
4
4
3
4
4
4
3
4
4
3
4
4
3
3
3
4

result:

ok 100 numbers

Extra Test:

score: 0
Extra Test Passed