QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#499412#7676. Wire CrossingMax_s_xaMAC ✓26ms34724kbC++1412.3kb2024-07-31 13:57:572024-07-31 13:57:57

Judging History

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

  • [2024-07-31 13:57:57]
  • 评测
  • 测评结果:AC
  • 用时:26ms
  • 内存:34724kb
  • [2024-07-31 13:57:57]
  • 提交

answer

#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>

typedef long long ll;
typedef long double lf;

// #define DEBUG 1
struct IO
{
    #define MAXSIZE (1 << 20)
    #define isdigit(x) (x >= '0' && x <= '9')
    char buf[MAXSIZE], *p1, *p2;
    char pbuf[MAXSIZE], *pp;
    #if DEBUG
    #else
    IO() : p1(buf), p2(buf), pp(pbuf) {}
    ~IO() {fwrite(pbuf, 1, pp - pbuf, stdout);}
    #endif
    #define gc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin), p1 == p2) ? ' ' : *p1++)
    #define blank(x) (x == ' ' || x == '\n' || x == '\r' || x == '\t')

    template <typename T>
    void Read(T &x)
    {
        #if DEBUG
        std::cin >> x;
        #else
        bool sign = 0; char ch = gc(); x = 0;
        for (; !isdigit(ch); ch = gc())
            if (ch == '-') sign = 1;
        for (; isdigit(ch); ch = gc()) x = x * 10 + (ch ^ 48);
        if (sign) x = -x;
        #endif
    }
    void Read(char *s)
    {
        #if DEBUG
        std::cin >> s;
        #else
        char ch = gc();
        for (; blank(ch); ch = gc());
        for (; !blank(ch); ch = gc()) *s++ = ch;
        *s = 0;
        #endif
    }
    void Read(char &c) {for (c = gc(); blank(c); c = gc());}

    void Push(const char &c)
    {
        #if DEBUG
        putchar(c);
        #else
        if (pp - pbuf == MAXSIZE) fwrite(pbuf, 1, MAXSIZE, stdout), pp = pbuf;
        *pp++ = c;
        #endif
    }
    template <typename T>
    void Write(T x)
    {
        if (x < 0) x = -x, Push('-');
        static T sta[35];
        int top = 0;
        do sta[top++] = x % 10, x /= 10; while (x);
        while (top) Push(sta[--top] ^ 48);
    }
    template <typename T>
    void Write(T x, char lst) {Write(x), Push(lst);}
} IO;
#define Read(x) IO.Read(x)
#define Write(x, y) IO.Write(x, y)
#define Put(x) IO.Push(x)

using namespace std;

const int MAXN = 4e4 + 10, MAXM = 210;

int n, m, et, vt, ss, tt;

const lf eps = 1e-12, pi = acos(-1.0);
inline int sgn(lf x) { return x > eps ? 1 : (x < -eps ? -1 : 0); }
struct Point
{
    lf x, y;
    Point(lf _x = 0, lf _y = 0) : x(_x), y(_y) {}
    Point operator + (const Point &u) const { return Point(x + u.x, y + u.y); }
    Point operator - (const Point &u) const { return Point(x - u.x, y - u.y); }
    Point operator * (const lf u) const { return Point(x * u, y * u); }
    Point operator / (const lf u) const { return Point(x / u, y / u); }
    bool operator == (const Point &u) const { return sgn(x - u.x) == 0 && sgn(y - u.y) == 0; }
    bool operator < (const Point &u) const
    {
        if (sgn(x - u.x) == 0) return sgn(y - u.y) < 0;
        return sgn(x - u.x) < 0;
    }
    friend ostream& operator << (ostream& out, Point u)
    {
        out << u.x << ' ' << u.y;
        return out;
    }
};
inline lf dot(const Point &u, const Point &v) { return u.x * v.x + u.y * v.y; }
inline lf det(const Point &u, const Point &v) { return u.x * v.y - u.y * v.x; }
inline bool quadrant(const Point &u)
{
    if (sgn(u.y) == 0) return sgn(u.x) < 0;
    return sgn(u.y) < 0;
}
inline lf sqr(lf x) { return x * x; }
inline lf dist(const Point &u) { return sqrt(sqr(u.x) + sqr(u.y)); }
struct Line
{
    Point s, t;
};
inline bool Two_side(const Point &a, const Point &b, const Line &c)
{
    return sgn(det(a - c.s, c.t - c.s)) * sgn(det(b - c.s, c.t - c.s)) < 0;
}
inline bool Point_on_segment(const Point &a, const Line &l)
{
    return sgn(det(l.s - a, a - l.t)) == 0 && sgn(dot(l.s - a, a - l.t)) >= 0;
}
inline bool Inter_judge(const Line &a, const Line &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 1;
    return Two_side(a.s, a.t, b) && Two_side(b.s, b.t, a);
}
inline Point Line_intersect(const Line &u, const Line &v)
{
    if (Point_on_segment(u.s, v)) return u.s;
    if (Point_on_segment(u.t, v)) return u.t;
    if (Point_on_segment(v.s, u)) return v.s;
    if (Point_on_segment(v.t, u)) return v.t;
    lf x = det(u.t - u.s, v.s - u.s), y = -det(u.t - u.s, v.t - u.s);
    return (v.s * y + v.t * x) / (x + y);
}
inline lf angle(const Point &u, const Point &v)
{
    lf ang = atan2(u.x, u.y) - atan2(v.x, v.y);
    if (sgn(ang - pi) > 0) ang -= 2 * pi;
    else if (sgn(ang + pi) < 0) ang += 2 * pi;
    return ang; 
}

Point S, T;
Line a[MAXM];

typedef unsigned long long ull;
const ull B = 13331;
map <ull, bool> mp;
inline ull Trs(const Line &u) { ull a = (ull)u.s.x * B + (ull)u.s.y, b = (ull)u.t.x * B + (ull)u.t.y; if (a > b) swap(a, b); return a * B * B + b; }

Point nd[MAXN];
vector <Point> _it[MAXM];
vector <int> it[MAXM];
struct Node
{
    int v, id;
    Point pt;
    Node (int a, int b, Point c) : v(a), id(b), pt(c) {}
};
vector <Node> g[MAXN];
inline bool cmp(const Node &u, const Node &v)
{
    bool a = quadrant(u.pt), b = quadrant(v.pt);
    if (a ^ b) return a < b;
    int s = sgn(det(u.pt, v.pt));
    if (s == 0) return sgn(dist(u.pt) - dist(v.pt)) < 0;
    return s > 0;
}

Line sgt[MAXN << 2];
int val[MAXN << 2];
map <int, bool> vis[MAXN];
map <int, int> idx[MAXN];

int st[MAXN << 2], top;
int st2[MAXN << 2], top2;
inline void DFS(int u, int ed)
{
    st2[++top2] = u;
    if (g[u].size() == 1) return st[++top] = g[u][0].id, DFS(g[u][0].v, g[u][0].id), void();
    int cur = idx[u][ed];
    if (cur == g[u].size() - 1) cur = 0; else cur++;
    int b = g[u][cur].v, v = g[u][cur].id;
    if (!vis[ed][v]) vis[ed][v] = 1, st[++top] = v, DFS(b, v);
}

int mrk[MAXN];
vector <int> fed[MAXN << 1];
vector <pair <int, int>> e[MAXN << 1], tmp;

int dis[MAXN << 1]; bool avl[MAXN << 1];
vector <int> q0;
queue <int> q1;

int main()
{
    // freopen("A.in", "r", stdin);
    // freopen("A.out", "w", stdout);
    #if DEBUG
    #else
    ios::sync_with_stdio(0), cin.tie(0);
    #endif
    Read(m), Read(S.x), Read(S.y), Read(T.x), Read(T.y);
    for (int i = 1; i <= m; i++)
    {
        Read(a[i].s.x), Read(a[i].s.y), Read(a[i].t.x), Read(a[i].t.y);
        mp[Trs(a[i])] = 1;
        // cout << "Segment((" << a[i].s.x << "," << a[i].s.y << "),(" << a[i].t.x << "," << a[i].t.y << "))\n";
    }
    // cout << '\n';
    int _m = m;
    for (int i = 1; i < m; i++)
    {
        if (a[i].s == a[i + 1].s) continue;
        Line cur = Line{a[i].s, a[i + 1].s};
        if (!mp[Trs(cur)]) a[++_m] = cur;
    }
    swap(m, _m);
    // for (int i = 1; i <= m; i++)
    // {
    //     cout << "Segment((" << a[i].s.x << "," << a[i].s.y << "),(" << a[i].t.x << "," << a[i].t.y << "))\n";
    // }

    for (int i = 1; i <= m; i++)
        for (int j = i + 1; j <= m; j++)
            if (Inter_judge(a[i], a[j]))
            {
                auto x = Line_intersect(a[i], a[j]);
                nd[++n] = x;
                _it[i].push_back(x), _it[j].push_back(x);
            }
    sort(nd + 1, nd + n + 1);
    // cout << fixed << setprecision(20);
    // for (int i = 1; i <= n; i++) cout << nd[i] << '\n'; cout << '\n';
    n = unique(nd + 1, nd + n + 1) - nd - 1;


    // cout << Inter_judge(a[1], a[4]) << '\n';
    // cout << a[1].s << ' ' << a[1].t << ' ' << a[4].s << ' ' << a[4].t << '\n';
    // cout << Point_on_segment(a[1].s, a[4]) << '\n';
    // cout << a[4].s - a[1].s << ' ' << a[1].s - a[4].t << '\n';
    // cout << sgn(det(a[4].s - a[1].s, a[1].s - a[4].t)) << ' ' << sgn(dot(a[4].s - a[1].s, a[1].s - a[4].t)) << '\n';
    // for (int i = 1; i <= n; i++) cout << nd[i] << '\n';
    // for (int i = 1; i <= m; i++)
    // {
    //     cout << "sgt " << i << ": ";
    //     for (auto x : _it[i]) cout << x << ' '; cout << '\n';
    // }

    for (int i = 1; i <= m; i++)
    {
        for (auto x : _it[i])
        {
            int cur = lower_bound(nd + 1, nd + n + 1, x) - nd;
            it[i].push_back(cur);
        }
        sort(it[i].begin(), it[i].end()), it[i].resize(unique(it[i].begin(), it[i].end()) - it[i].begin());
        // cout << "sgt " << i << ": ";
        // for (auto x : it[i]) cout << x << ' '; cout << '\n';
        // for (int j = 1; j < it[i].size(); j++) cout << it[i][j - 1] << ' ' << it[i][j] << '\n';
        for (int j = 1; j < it[i].size(); j++)
        {
            if (idx[it[i][j]][it[i][j - 1]]) { val[et] = max(val[et], (int)(i <= _m)); continue; }
            idx[it[i][j]][it[i][j - 1]] = idx[it[i][j - 1]][it[i][j]] = ++et;
            val[et] = (i <= _m), sgt[et] = Line{nd[it[i][j]], nd[it[i][j - 1]]};
            // cout << "Ed: " << it[i][j] << ' ' << it[i][j - 1] << ' ' << val[et] << '\n';
            g[it[i][j - 1]].emplace_back(it[i][j], et, nd[it[i][j]] - nd[it[i][j - 1]]);
            g[it[i][j]].emplace_back(it[i][j - 1], et, nd[it[i][j - 1]] - nd[it[i][j]]);
        }
    }
    for (int i = 1; i <= n; i++) idx[i].clear();
    // for (int i = 1; i <= et; i++)
    //     cout << sgt[i].s << ' ' << sgt[i].t << ' ' << val[i] << "\n";
    for (int i = 1; i <= n; i++)
    {
        sort(g[i].begin(), g[i].end(), cmp);
        for (int j = 0; j < g[i].size(); j++)
            idx[i][g[i][j].id] = j;
        // cout << "pt " << i << '\n';
        // for (auto x : g[i])
        //     cout << x.v << ' '; cout << '\n';
    }
    
    vt++;
    for (int i = 1; i <= n; i++)
    {
        if (g[i].size() <= 1) continue;
        for (int j = 0; j < g[i].size(); j++)
        {
            int u = g[i][j].id, v = g[i][(j + 1 == g[i].size() ? 0 : j + 1)].id;
            int a = g[i][j].v, b = g[i][(j + 1 == g[i].size() ? 0 : j + 1)].v;
            if (!vis[u][v])
            {
                st[top = 1] = v, top2 = 0, vis[u][v] = 1, DFS(b, v);
                lf suf = 0;
                for (int k = 1; k <= top2; k++)
                    suf += det(nd[st2[k]], nd[st2[k == top2 ? 1 : k + 1]]);
                if (sgn(suf) > 0)
                {
                    for (int k = 1; k <= top; k++)
                        if (mrk[st[k]]) e[1].emplace_back(mrk[st[k]], val[st[k]]), e[mrk[st[k]]].emplace_back(1, val[st[k]]);
                        else mrk[st[k]] = 1;
                }
                else
                {
                    vt++;
                    while (top2) fed[vt].push_back(st2[top2--]);
                    for (int k = 1; k <= top; k++)
                        if (mrk[st[k]]) e[vt].emplace_back(mrk[st[k]], val[st[k]]), e[mrk[st[k]]].emplace_back(vt, val[st[k]]);
                        else mrk[st[k]] = vt;
                }
            }
        }
    }
    // cout << vt << "\n";
    // for (int i = 1; i <= vt; i++)
    // {
    //     cout << "face " << i << ":\n";
    //     for (auto x : fed[i]) cout << x << ' '; cout << '\n';
    // }
    for (int i = 1; i <= vt; i++)
    {
        sort(e[i].begin(), e[i].end());
        tmp.clear();
        for (auto [v, w] : e[i])
            if (!tmp.size() || (tmp.back().first != v)) tmp.emplace_back(v, w);
        e[i] = tmp;
    }
    // for (int i = 1; i <= vt; i++)
    // {
    //     cout << i << ": ";
    //     for (auto [v, w] : e[i]) cout << v << " " << w << ' '; cout << '\n';
    // }
    ss = tt = 1;
    for (int i = 2; i <= vt; i++)
    {
        lf sum = 0;
        for (int j = 0; j < fed[i].size(); j++)
            sum += angle(nd[fed[i][j]] - S, nd[fed[i][(j + 1 == fed[i].size() ? 0 : j + 1)]] - S);
        if (sgn(sum) != 0) { ss = i; break; }
    }
    for (int i = 2; i <= vt; i++)
    {
        lf sum = 0;
        for (int j = 0; j < fed[i].size(); j++)
            sum += angle(nd[fed[i][j]] - T, nd[fed[i][(j + 1 == fed[i].size() ? 0 : j + 1)]] - T);
        if (sgn(sum) != 0) { tt = i; break; }
    }

    // cout << ss << ' ' << tt << "\n";

    for (int i = 1; i <= vt; i++) dis[i] = 2e9;
    dis[ss] = 0, q0.push_back(ss);
    while (!q0.empty() || !q1.empty())
    {
        int u;
        if (!q0.empty()) u = q0.back(), q0.pop_back();
        else u = q1.front(), q1.pop();
        if (avl[u]) continue;
        avl[u] = 1;
        for (auto [v, w] : e[u])
            if (dis[v] > dis[u] + w)
            {
                dis[v] = dis[u] + w;
                if (w == 0) q0.push_back(v);
                else q1.push(v);
            }
    }
    cout << dis[tt] << '\n';
    // for (int i = 1; i <= vt; i++) cout << dis[i] << ' '; cout << '\n';
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 25664kb

input:

8 3 3 19 3
0 1 22 1
0 5 22 5
1 0 1 6
5 0 5 6
9 0 9 6
13 0 13 6
17 0 17 6
21 0 21 6

output:

2

result:

ok single line: '2'

Test #2:

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

input:

1 0 5 10 5
0 0 10 10

output:

0

result:

ok single line: '0'

Test #3:

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

input:

10 99998 0 -99998 0
99999 -99999 99999 99999
-99999 -99999 99999 -99999
-99999 99999 -99999 -99999
99999 99999 -99999 99999
99999 -99999 99998 1
99998 1 99997 -99998
99997 -99998 99999 -99999
-99999 99999 -99998 -1
-99998 -1 -99997 99998
-99997 99998 -99999 99999

output:

2

result:

ok single line: '2'

Test #4:

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

input:

11 99998 0 -99998 0
-99999 -1 99999 1
99999 -99999 99999 99999
-99999 -99999 99999 -99999
-99999 99999 -99999 -99999
99999 99999 -99999 99999
99999 -99999 99998 1
99998 1 99997 -99998
99997 -99998 99999 -99999
-99999 99999 -99998 -1
-99998 -1 -99997 99998
-99997 99998 -99999 99999

output:

3

result:

ok single line: '3'

Test #5:

score: 0
Accepted
time: 3ms
memory: 25756kb

input:

12 99998 0 -99998 0
99999 -99999 99999 99999
-99999 -99999 99999 -99999
-99999 -99999 99999 99999
-99999 99999 -99999 -99998
99998 99999 -99999 99999
-99999 -99998 99998 99999
99999 -99999 99998 1
99998 1 99997 -99998
99997 -99998 99999 -99999
-99999 99999 -99998 -1
-99998 -1 -99997 99998
-99997 999...

output:

4

result:

ok single line: '4'

Test #6:

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

input:

11 -99997 99997 99997 99997
-99999 99999 99999 99999
-99999 99998 99999 99998
-99999 99996 99999 99996
-99999 99995 99999 99995
-99999 -99999 -99999 99999
-99998 -99999 -99998 99999
99999 -99999 99999 99999
99998 -99999 99998 99999
5 99999 5 -99999
5 99999 6 -99999
5 99999 4 -99999

output:

3

result:

ok single line: '3'

Test #7:

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

input:

11 99997 -99997 99997 99997
99999 -99999 99999 99999
99998 -99999 99998 99999
99996 -99999 99996 99999
99995 -99999 99995 99999
-99999 -99999 99999 -99999
-99999 -99998 99999 -99998
-99999 99999 99999 99999
-99999 99998 99999 99998
99999 5 -99999 5
99999 5 -99999 6
99999 5 -99999 4

output:

3

result:

ok single line: '3'

Test #8:

score: 0
Accepted
time: 6ms
memory: 26304kb

input:

0 1023 4923 -239 14933

output:

0

result:

ok single line: '0'

Test #9:

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

input:

7 3 3 15 3
0 1 18 1
0 5 18 5
1 0 1 6
5 0 5 6
9 0 9 6
13 0 13 6
17 0 17 6

output:

2

result:

ok single line: '2'

Test #10:

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

input:

0 0 0 0 1

output:

0

result:

ok single line: '0'

Test #11:

score: 0
Accepted
time: 2ms
memory: 26176kb

input:

0 1 0 1 0

output:

0

result:

ok single line: '0'

Test #12:

score: 0
Accepted
time: 2ms
memory: 25912kb

input:

1 0 0 0 0
10 10 20 20

output:

0

result:

ok single line: '0'

Test #13:

score: 0
Accepted
time: 5ms
memory: 25648kb

input:

1 0 0 -10 0
-5 -5 -5 15

output:

0

result:

ok single line: '0'

Test #14:

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

input:

1 -10 -10 10 10
-5 -5 5 5

output:

0

result:

ok single line: '0'

Test #15:

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

input:

2 0 0 10 0
3 -5 3 5
6 5 6 -5

output:

0

result:

ok single line: '0'

Test #16:

score: 0
Accepted
time: 6ms
memory: 27352kb

input:

2 -5 0 5 0
-10 10 10 -10
-10 -10 10 10

output:

0

result:

ok single line: '0'

Test #17:

score: 0
Accepted
time: 7ms
memory: 26092kb

input:

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

output:

0

result:

ok single line: '0'

Test #18:

score: 0
Accepted
time: 7ms
memory: 27264kb

input:

3 0 0 0 13
-10 -10 10 -10
-9 -11 9 20
9 -11 -9 20

output:

1

result:

ok single line: '1'

Test #19:

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

input:

3 0 -11 0 13
-10 -10 10 -10
-9 -11 9 20
9 -11 -9 20

output:

0

result:

ok single line: '0'

Test #20:

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

input:

3 0 5 -1 -6
-10 0 10 0
5 10 5 -10
-5 8 -5 -17

output:

0

result:

ok single line: '0'

Test #21:

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

input:

4 1 1 -1 -1
0 0 0 5
0 0 5 0
5 5 5 0
5 5 0 5

output:

1

result:

ok single line: '1'

Test #22:

score: 0
Accepted
time: 12ms
memory: 31280kb

input:

100 -96667 14 -98020 22
-99999 0 99999 0
-99999 1 99999 -1
-99999 2 99999 -4
-99999 3 99999 -9
-99999 4 99999 -16
-99999 5 99999 -25
-99999 6 99999 -36
-99999 7 99999 -49
-99999 8 99999 -64
-99999 9 99999 -81
-99999 10 99999 -100
-99999 11 99999 -121
-99999 12 99999 -144
-99999 13 99999 -169
-99999 ...

output:

41

result:

ok single line: '41'

Test #23:

score: 0
Accepted
time: 21ms
memory: 30596kb

input:

100 12 -95437 22 -98020
0 -99999 0 99999
1 -99999 -1 99999
2 -99999 -4 99999
3 -99999 -9 99999
4 -99999 -16 99999
5 -99999 -25 99999
6 -99999 -36 99999
7 -99999 -49 99999
8 -99999 -64 99999
9 -99999 -81 99999
10 -99999 -100 99999
11 -99999 -121 99999
12 -99999 -144 99999
13 -99999 -169 99999
14 -999...

output:

33

result:

ok single line: '33'

Test #24:

score: 0
Accepted
time: 7ms
memory: 25720kb

input:

4 0 0 0 -11
-10 -10 10 -10
-10 -7 10 -7
-9 -12 9 20
9 -12 -9 20

output:

1

result:

ok single line: '1'

Test #25:

score: 0
Accepted
time: 3ms
memory: 26504kb

input:

6 0 0 20 20
-10 -10 10 -10
-9 -11 9 20
9 -11 -9 20
-10 10 10 10
-9 11 9 -20
9 11 -9 -20

output:

2

result:

ok single line: '2'

Test #26:

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

input:

9 10 11 -100 -100
0 0 10 25
10 25 20 0
20 0 0 20
0 20 20 20
20 20 0 0
1 1 19 1
1 1 1 21
1 21 19 21
19 21 19 1

output:

3

result:

ok single line: '3'

Test #27:

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

input:

40 0 0 1000 1000
-22 -18 20 -18
-22 18 20 18
-21 -19 -21 19
19 -19 19 19
-42 -41 40 -41
-42 42 40 42
-41 -42 -41 43
39 -42 39 43
-61 -58 59 -58
-61 58 59 58
-60 -59 -60 59
58 -59 58 59
-80 -78 80 -78
-80 80 80 80
-79 -79 -79 81
79 -79 79 81
-100 -101 103 -101
-100 98 103 98
-99 -102 -99 99
102 -102 ...

output:

10

result:

ok single line: '10'

Test #28:

score: 0
Accepted
time: 3ms
memory: 26184kb

input:

24 15 15 115 115
0 0 0 30
30 0 0 0
10 0 10 30
30 10 0 10
20 0 20 30
30 20 0 20
30 0 30 30
30 30 0 30
-10 -10 40 -10
-10 -10 -10 40
-10 40 40 40
40 -10 40 40
100 100 100 130
130 100 100 100
110 100 110 130
130 110 100 110
120 100 120 130
130 120 100 120
130 100 130 130
130 130 100 130
90 90 140 90
90...

output:

6

result:

ok single line: '6'

Test #29:

score: 0
Accepted
time: 26ms
memory: 34724kb

input:

96 329 329 649 650
-2 -8 2 972
970 -1 -8 2
21 -10 21 969
970 20 -12 20
41 -8 42 970
970 38 -12 39
61 -8 61 968
971 61 -10 60
79 -11 81 970
968 80 -8 79
99 -12 101 969
969 101 -11 102
120 -8 118 968
971 120 -10 119
142 -10 141 968
969 140 -9 142
161 -10 162 971
972 160 -11 160
182 -9 178 968
970 179 ...

output:

32

result:

ok single line: '32'

Test #30:

score: 0
Accepted
time: 11ms
memory: 29776kb

input:

100 220 220 -220 -220
-403 623 60 -950
763 20 -972 114
-533 -38 -437 -878
-191 -899 317 129
473 -746 62 -655
572 -18 -202 815
-967 925 511 -976
804 404 542 -117
-328 -217 91 -75
863 -326 999 8
565 933 708 -241
912 -984 -336 475
914 643 -817 -625
-924 -337 834 628
31 -341 -900 -175
658 -411 922 -378
...

output:

20

result:

ok single line: '20'

Test #31:

score: 0
Accepted
time: 3ms
memory: 27540kb

input:

20 -11 -11 15 15
0 0 0 4
0 4 4 4
4 4 4 0
4 0 0 0
-4 -4 -4 8
-4 8 8 8
8 8 8 -4
8 -4 -4 -4
-8 -8 -8 12
-8 12 12 12
12 12 12 -8
12 -8 -8 -8
-12 -12 -12 16
-12 16 16 16
16 16 16 -12
16 -12 -12 -12
-16 -16 -16 20
-16 20 20 20
20 20 20 -16
20 -16 -16 -16

output:

0

result:

ok single line: '0'

Test #32:

score: 0
Accepted
time: 3ms
memory: 26988kb

input:

20 -30 2 -14 2
0 0 0 4
0 4 4 4
4 4 4 0
4 0 0 0
-4 -4 -4 8
-4 8 8 8
8 8 8 -4
8 -4 -4 -4
-8 -8 -8 12
-8 12 12 12
12 12 12 -8
12 -8 -8 -8
-12 -12 -12 16
-12 16 16 16
16 16 16 -12
16 -12 -12 -12
-16 -16 -16 20
-16 20 20 20
20 20 20 -16
20 -16 -16 -16

output:

1

result:

ok single line: '1'

Test #33:

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

input:

20 -30 2 -6 2
0 0 0 4
0 4 4 4
4 4 4 0
4 0 0 0
-4 -4 -4 8
-4 8 8 8
8 8 8 -4
8 -4 -4 -4
-8 -8 -8 12
-8 12 12 12
12 12 12 -8
12 -8 -8 -8
-12 -12 -12 16
-12 16 16 16
16 16 16 -12
16 -12 -12 -12
-16 -16 -16 20
-16 20 20 20
20 20 20 -16
20 -16 -16 -16

output:

3

result:

ok single line: '3'

Test #34:

score: 0
Accepted
time: 3ms
memory: 27188kb

input:

20 -30 2 2 2
0 0 0 4
0 4 4 4
4 4 4 0
4 0 0 0
-4 -4 -4 8
-4 8 8 8
8 8 8 -4
8 -4 -4 -4
-8 -8 -8 12
-8 12 12 12
12 12 12 -8
12 -8 -8 -8
-12 -12 -12 16
-12 16 16 16
16 16 16 -12
16 -12 -12 -12
-16 -16 -16 20
-16 20 20 20
20 20 20 -16
20 -16 -16 -16

output:

5

result:

ok single line: '5'

Test #35:

score: 0
Accepted
time: 5ms
memory: 26256kb

input:

20 -30 2 6 2
0 0 0 4
0 4 4 4
4 4 4 0
4 0 0 0
-4 -4 -4 8
-4 8 8 8
8 8 8 -4
8 -4 -4 -4
-8 -8 -8 12
-8 12 12 12
12 12 12 -8
12 -8 -8 -8
-12 -12 -12 16
-12 16 16 16
16 16 16 -12
16 -12 -12 -12
-16 -16 -16 20
-16 20 20 20
20 20 20 -16
20 -16 -16 -16

output:

4

result:

ok single line: '4'

Test #36:

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

input:

20 -30 2 14 2
0 0 0 4
0 4 4 4
4 4 4 0
4 0 0 0
-4 -4 -4 8
-4 8 8 8
8 8 8 -4
8 -4 -4 -4
-8 -8 -8 12
-8 12 12 12
12 12 12 -8
12 -8 -8 -8
-12 -12 -12 16
-12 16 16 16
16 16 16 -12
16 -12 -12 -12
-16 -16 -16 20
-16 20 20 20
20 20 20 -16
20 -16 -16 -16

output:

2

result:

ok single line: '2'

Test #37:

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

input:

20 -30 2 30 2
0 0 0 4
0 4 4 4
4 4 4 0
4 0 0 0
-4 -4 -4 8
-4 8 8 8
8 8 8 -4
8 -4 -4 -4
-8 -8 -8 12
-8 12 12 12
12 12 12 -8
12 -8 -8 -8
-12 -12 -12 16
-12 16 16 16
16 16 16 -12
16 -12 -12 -12
-16 -16 -16 20
-16 20 20 20
20 20 20 -16
20 -16 -16 -16

output:

0

result:

ok single line: '0'

Test #38:

score: 0
Accepted
time: 4ms
memory: 27352kb

input:

84 25 6 -25 6
0 0 100 0
0 0 100 10
0 0 100 20
0 0 100 30
0 0 100 40
0 0 100 50
0 0 100 60
0 0 100 70
0 0 100 80
0 0 100 90
0 0 100 100
0 0 90 100
0 0 80 100
0 0 70 100
0 0 60 100
0 0 50 100
0 0 40 100
0 0 30 100
0 0 20 100
0 0 10 100
0 0 0 100
0 0 -10 100
0 0 -20 100
0 0 -30 100
0 0 -40 100
0 0 -50 ...

output:

2

result:

ok single line: '2'

Test #39:

score: 0
Accepted
time: 3ms
memory: 26560kb

input:

80 25 6 -25 6
0 0 100 0
0 0 100 10
0 0 100 20
0 0 100 30
0 0 100 40
0 0 100 50
0 0 100 60
0 0 100 70
0 0 100 80
0 0 100 90
0 0 100 100
0 0 90 100
0 0 80 100
0 0 70 100
0 0 60 100
0 0 50 100
0 0 40 100
0 0 30 100
0 0 20 100
0 0 10 100
0 0 0 100
0 0 -10 100
0 0 -20 100
0 0 -30 100
0 0 -40 100
0 0 -50 ...

output:

0

result:

ok single line: '0'

Test #40:

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

input:

84 25 6 51 6
0 0 100 0
0 0 100 10
0 0 100 20
0 0 100 30
0 0 100 40
0 0 100 50
0 0 100 60
0 0 100 70
0 0 100 80
0 0 100 90
0 0 100 100
0 0 90 100
0 0 80 100
0 0 70 100
0 0 60 100
0 0 50 100
0 0 40 100
0 0 30 100
0 0 20 100
0 0 10 100
0 0 0 100
0 0 -10 100
0 0 -20 100
0 0 -30 100
0 0 -40 100
0 0 -50 1...

output:

1

result:

ok single line: '1'

Test #41:

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

input:

80 25 6 51 6
0 0 100 0
0 0 100 10
0 0 100 20
0 0 100 30
0 0 100 40
0 0 100 50
0 0 100 60
0 0 100 70
0 0 100 80
0 0 100 90
0 0 100 100
0 0 90 100
0 0 80 100
0 0 70 100
0 0 60 100
0 0 50 100
0 0 40 100
0 0 30 100
0 0 20 100
0 0 10 100
0 0 0 100
0 0 -10 100
0 0 -20 100
0 0 -30 100
0 0 -40 100
0 0 -50 1...

output:

0

result:

ok single line: '0'

Test #42:

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

input:

8 10 10 9 9
0 0 10 0
0 5 10 5
0 10 6 10
0 15 10 15
0 0 0 10
5 0 5 10
10 0 10 6
15 0 15 10

output:

0

result:

ok single line: '0'

Test #43:

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

input:

8 10 10 9 11
0 0 10 0
0 5 10 5
0 10 6 10
0 15 10 15
0 0 0 10
5 0 5 10
10 0 10 6
15 0 15 10

output:

0

result:

ok single line: '0'

Test #44:

score: 0
Accepted
time: 7ms
memory: 27320kb

input:

8 10 10 11 11
0 0 10 0
0 5 10 5
0 10 6 10
0 15 10 15
0 0 0 10
5 0 5 10
10 0 10 6
15 0 15 10

output:

0

result:

ok single line: '0'

Test #45:

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

input:

8 10 10 11 9
0 0 10 0
0 5 10 5
0 10 6 10
0 15 10 15
0 0 0 10
5 0 5 10
10 0 10 6
15 0 15 10

output:

0

result:

ok single line: '0'

Test #46:

score: 0
Accepted
time: 3ms
memory: 26720kb

input:

67 1 1 -1 1
0 -1 0 6
-1 5 6 5
-1 0 11 0
5 4 5 11
10 -1 10 16
6 10 -6 10
11 15 -11 15
-5 11 -5 -6
-10 16 -10 -11
-6 -5 16 -5
-11 -10 21 -10
15 -6 15 21
20 -11 20 26
16 20 -16 20
21 25 -21 25
-15 21 -15 -16
-20 26 -20 -21
-16 -15 26 -15
-21 -20 31 -20
25 -16 25 31
30 -21 30 36
26 30 -26 30
31 35 -31 3...

output:

0

result:

ok single line: '0'

Test #47:

score: 0
Accepted
time: 3ms
memory: 25932kb

input:

67 1 1 -100 1
0 -1 0 6
-1 5 6 5
-1 0 11 0
5 4 5 11
10 -1 10 16
6 10 -6 10
11 15 -11 15
-5 11 -5 -6
-10 16 -10 -11
-6 -5 16 -5
-11 -10 21 -10
15 -6 15 21
20 -11 20 26
16 20 -16 20
21 25 -21 25
-15 21 -15 -16
-20 26 -20 -21
-16 -15 26 -15
-21 -20 31 -20
25 -16 25 31
30 -21 30 36
26 30 -26 30
31 35 -31...

output:

0

result:

ok single line: '0'

Test #48:

score: 0
Accepted
time: 3ms
memory: 26788kb

input:

68 1 1 -1 1
0 -1 0 6
-1 5 6 5
-1 0 11 0
5 4 5 11
10 -1 10 16
6 10 -6 10
11 15 -11 15
-5 11 -5 -6
-10 16 -10 -11
-6 -5 16 -5
-11 -10 21 -10
15 -6 15 21
20 -11 20 26
16 20 -16 20
21 25 -21 25
-15 21 -15 -16
-20 26 -20 -21
-16 -15 26 -15
-21 -20 31 -20
25 -16 25 31
30 -21 30 36
26 30 -26 30
31 35 -31 3...

output:

1

result:

ok single line: '1'

Test #49:

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

input:

68 1 1 -100 1
0 -1 0 6
-1 5 6 5
-1 0 11 0
5 4 5 11
10 -1 10 16
6 10 -6 10
11 15 -11 15
-5 11 -5 -6
-10 16 -10 -11
-6 -5 16 -5
-11 -10 21 -10
15 -6 15 21
20 -11 20 26
16 20 -16 20
21 25 -21 25
-15 21 -15 -16
-20 26 -20 -21
-16 -15 26 -15
-21 -20 31 -20
25 -16 25 31
30 -21 30 36
26 30 -26 30
31 35 -31...

output:

1

result:

ok single line: '1'

Test #50:

score: 0
Accepted
time: 7ms
memory: 27480kb

input:

100 69 93 83 93
0 0 98 0
0 2 98 2
0 4 98 4
0 6 98 6
0 8 98 8
0 10 98 10
0 12 98 12
0 14 98 14
0 16 98 16
0 18 98 18
0 20 98 20
0 22 98 22
0 24 98 24
0 26 98 26
0 28 98 28
0 30 98 30
0 32 98 32
0 34 98 34
0 36 98 36
0 38 98 38
0 40 98 40
0 42 98 42
0 44 98 44
0 46 98 46
0 48 98 48
0 50 98 50
0 52 98 ...

output:

6

result:

ok single line: '6'

Test #51:

score: 0
Accepted
time: 13ms
memory: 29244kb

input:

100 69 91 83 91
0 0 98 0
0 2 98 2
0 4 98 4
0 6 98 6
0 8 98 8
0 10 98 10
0 12 98 12
0 14 98 14
0 16 98 16
0 18 98 18
0 20 98 20
0 22 98 22
0 24 98 24
0 26 98 26
0 28 98 28
0 30 98 30
0 32 98 32
0 34 98 34
0 36 98 36
0 38 98 38
0 40 98 40
0 42 98 42
0 44 98 44
0 46 98 46
0 48 98 48
0 50 98 50
0 52 98 ...

output:

7

result:

ok single line: '7'

Test #52:

score: 0
Accepted
time: 13ms
memory: 28444kb

input:

100 33 91 83 91
0 0 98 0
0 2 98 2
0 4 98 4
0 6 98 6
0 8 98 8
0 10 98 10
0 12 98 12
0 14 98 14
0 16 98 16
0 18 98 18
0 20 98 20
0 22 98 22
0 24 98 24
0 26 98 26
0 28 98 28
0 30 98 30
0 32 98 32
0 34 98 34
0 36 98 36
0 38 98 38
0 40 98 40
0 42 98 42
0 44 98 44
0 46 98 46
0 48 98 48
0 50 98 50
0 52 98 ...

output:

8

result:

ok single line: '8'

Test #53:

score: 0
Accepted
time: 9ms
memory: 27664kb

input:

100 33 73 83 73
0 0 98 0
0 2 98 2
0 4 98 4
0 6 98 6
0 8 98 8
0 10 98 10
0 12 98 12
0 14 98 14
0 16 98 16
0 18 98 18
0 20 98 20
0 22 98 22
0 24 98 24
0 26 98 26
0 28 98 28
0 30 98 30
0 32 98 32
0 34 98 34
0 36 98 36
0 38 98 38
0 40 98 40
0 42 98 42
0 44 98 44
0 46 98 46
0 48 98 48
0 50 98 50
0 52 98 ...

output:

21

result:

ok single line: '21'

Test #54:

score: 0
Accepted
time: 4ms
memory: 28784kb

input:

100 33 51 83 51
0 0 98 0
0 2 98 2
0 4 98 4
0 6 98 6
0 8 98 8
0 10 98 10
0 12 98 12
0 14 98 14
0 16 98 16
0 18 98 18
0 20 98 20
0 22 98 22
0 24 98 24
0 26 98 26
0 28 98 28
0 30 98 30
0 32 98 32
0 34 98 34
0 36 98 36
0 38 98 38
0 40 98 40
0 42 98 42
0 44 98 44
0 46 98 46
0 48 98 48
0 50 98 50
0 52 98 ...

output:

25

result:

ok single line: '25'

Test #55:

score: 0
Accepted
time: 8ms
memory: 28920kb

input:

100 31 51 83 51
0 0 98 0
0 2 98 2
0 4 98 4
0 6 98 6
0 8 98 8
0 10 98 10
0 12 98 12
0 14 98 14
0 16 98 16
0 18 98 18
0 20 98 20
0 22 98 22
0 24 98 24
0 26 98 26
0 28 98 28
0 30 98 30
0 32 98 32
0 34 98 34
0 36 98 36
0 38 98 38
0 40 98 40
0 42 98 42
0 44 98 44
0 46 98 46
0 48 98 48
0 50 98 50
0 52 98 ...

output:

24

result:

ok single line: '24'

Test #56:

score: 0
Accepted
time: 4ms
memory: 27836kb

input:

100 1 1 53 53
0 0 98 0
0 2 98 2
0 4 98 4
0 6 98 6
0 8 98 8
0 10 98 10
0 12 98 12
0 14 98 14
0 16 98 16
0 18 98 18
0 20 98 20
0 22 98 22
0 24 98 24
0 26 98 26
0 28 98 28
0 30 98 30
0 32 98 32
0 34 98 34
0 36 98 36
0 38 98 38
0 40 98 40
0 42 98 42
0 44 98 44
0 46 98 46
0 48 98 48
0 50 98 50
0 52 98 52...

output:

24

result:

ok single line: '24'

Test #57:

score: 0
Accepted
time: 12ms
memory: 28216kb

input:

100 1 1 57 57
0 0 98 0
0 2 98 2
0 4 98 4
0 6 98 6
0 8 98 8
0 10 98 10
0 12 98 12
0 14 98 14
0 16 98 16
0 18 98 18
0 20 98 20
0 22 98 22
0 24 98 24
0 26 98 26
0 28 98 28
0 30 98 30
0 32 98 32
0 34 98 34
0 36 98 36
0 38 98 38
0 40 98 40
0 42 98 42
0 44 98 44
0 46 98 46
0 48 98 48
0 50 98 50
0 52 98 52...

output:

22

result:

ok single line: '22'

Test #58:

score: 0
Accepted
time: 4ms
memory: 28640kb

input:

100 1 1 61 61
0 0 98 0
0 2 98 2
0 4 98 4
0 6 98 6
0 8 98 8
0 10 98 10
0 12 98 12
0 14 98 14
0 16 98 16
0 18 98 18
0 20 98 20
0 22 98 22
0 24 98 24
0 26 98 26
0 28 98 28
0 30 98 30
0 32 98 32
0 34 98 34
0 36 98 36
0 38 98 38
0 40 98 40
0 42 98 42
0 44 98 44
0 46 98 46
0 48 98 48
0 50 98 50
0 52 98 52...

output:

20

result:

ok single line: '20'

Test #59:

score: 0
Accepted
time: 12ms
memory: 27732kb

input:

100 1 1 91 91
0 0 98 0
0 2 98 2
0 4 98 4
0 6 98 6
0 8 98 8
0 10 98 10
0 12 98 12
0 14 98 14
0 16 98 16
0 18 98 18
0 20 98 20
0 22 98 22
0 24 98 24
0 26 98 26
0 28 98 28
0 30 98 30
0 32 98 32
0 34 98 34
0 36 98 36
0 38 98 38
0 40 98 40
0 42 98 42
0 44 98 44
0 46 98 46
0 48 98 48
0 50 98 50
0 52 98 52...

output:

5

result:

ok single line: '5'

Test #60:

score: 0
Accepted
time: 3ms
memory: 26488kb

input:

7 10002 999 -9999 0
-10001 -10001 -10001 10001
-10001 10001 10001 10001
10001 10001 10001 -10001
10001 -10001 -10001 -10001
-2 -2 0 2
0 2 2 -2
2 -2 -2 -2

output:

1

result:

ok single line: '1'

Test #61:

score: 0
Accepted
time: 8ms
memory: 29724kb

input:

100 637 348 568 270
-386 -768 -691 362
-496 206 854 184
-842 986 -908 -217
993 -67 -150 497
936 739 679 -896
-299 343 -119 879
176 -658 -69 -631
691 -944 196 862
-712 505 -220 -208
-290 -366 976 -575
-381 -933 -235 -388
-443 615 666 -508
-90 344 -847 611
-314 -409 490 419
-66 978 788 -819
-967 -460 ...

output:

1

result:

ok single line: '1'

Test #62:

score: 0
Accepted
time: 15ms
memory: 29952kb

input:

100 -219 518 -698 160
216 211 -744 240
889 243 380 404
-168 264 542 -269
142 671 -520 -791
107 827 -127 852
-476 -700 215 -677
31 -652 -357 369
423 -498 -915 -361
714 -659 879 602
141 258 5 974
-921 -896 -296 221
775 -259 430 -118
-875 -698 -710 -794
-398 505 -470 190
411 -270 -885 -167
233 -800 29 ...

output:

5

result:

ok single line: '5'

Test #63:

score: 0
Accepted
time: 15ms
memory: 29768kb

input:

100 -793 -541 891 -213
574 -848 -413 143
-176 863 149 -74
883 -294 -428 889
500 895 -114 -754
649 141 484 -730
775 654 950 917
-667 -647 -267 -460
-187 -377 -116 -614
-668 29 86 156
-109 792 -919 -670
-503 -790 777 554
-896 -338 358 753
360 -602 580 -308
-948 530 -835 -615
440 -545 -517 -748
78 367 ...

output:

0

result:

ok single line: '0'

Test #64:

score: 0
Accepted
time: 15ms
memory: 30696kb

input:

100 -259 -103 -803 146
592 -784 863 522
-323 734 527 -164
-953 -95 -607 -62
484 -780 63 -211
-171 -575 -626 663
-593 -585 441 -322
-734 297 378 -436
752 575 267 -100
349 130 -579 -975
-580 506 -582 -533
-590 -189 -38 894
31 -975 -760 418
-550 -829 80 -586
-413 -923 92 -590
-68 -974 -468 -760
602 799...

output:

8

result:

ok single line: '8'

Test #65:

score: 0
Accepted
time: 13ms
memory: 29448kb

input:

100 -54 -456 -799 552
93 215 146 532
-986 482 -217 -683
486 -67 -617 -341
-55 658 -985 18
950 839 -659 396
-591 32 -229 362
-767 -409 -889 -264
135 870 845 786
84 -10 317 98
-972 657 -28 514
-411 -88 -827 534
-873 746 -891 -924
585 -550 472 551
39 801 -530 -171
949 -419 565 83
-550 409 -575 91
956 3...

output:

9

result:

ok single line: '9'

Test #66:

score: 0
Accepted
time: 14ms
memory: 30324kb

input:

100 566 -467 72 -734
-866 827 598 542
-269 -466 50 352
-99 305 562 -277
679 912 400 -304
308 -359 928 -512
-660 898 109 218
672 180 -851 237
713 -222 61 404
-838 -785 -497 -107
-693 553 802 208
-143 363 488 -464
-169 -113 -211 -862
529 -284 -817 426
-387 -151 -799 842
-971 908 -364 299
-315 254 -740...

output:

4

result:

ok single line: '4'

Test #67:

score: 0
Accepted
time: 13ms
memory: 31408kb

input:

100 -260 -863 145 462
896 737 -416 -233
-7 66 -327 -545
610 769 967 417
731 443 -268 -439
64 -941 -986 873
521 -305 -965 743
-115 -258 -16 183
-120 686 -356 -225
423 228 99 973
851 329 -573 461
98 952 -566 -615
394 166 -53 -986
226 -482 444 -697
-230 479 -954 213
-779 -413 -605 -342
-728 39 -10 695
...

output:

7

result:

ok single line: '7'

Test #68:

score: 0
Accepted
time: 10ms
memory: 30100kb

input:

100 156 679 -249 -241
685 538 -904 -513
97 872 -424 -200
-469 -628 434 -795
254 -489 -65 -276
250 -795 -809 -610
-859 -535 842 -743
849 -88 -597 5
-853 155 321 389
-751 417 876 346
288 -548 -855 820
-176 136 582 635
204 -927 -642 -990
-722 -893 -600 -581
-428 800 -324 979
-732 -363 -460 -585
792 861...

output:

14

result:

ok single line: '14'

Test #69:

score: 0
Accepted
time: 21ms
memory: 31060kb

input:

100 -20 -799 607 939
420 -656 -517 453
-699 230 -228 857
-744 -837 -567 423
-377 -379 861 -503
742 -337 -36 -998
-664 927 -789 -388
-942 -882 298 38
877 -95 -467 296
-194 16 -694 108
-754 78 -479 -941
-201 -45 40 -21
133 -100 476 -125
563 997 -566 900
924 -355 -932 539
-680 367 -423 -804
829 110 492...

output:

1

result:

ok single line: '1'

Test #70:

score: 0
Accepted
time: 21ms
memory: 30580kb

input:

100 -2 -761 61 220
-562 -773 782 673
636 478 -531 -597
-382 515 -313 -445
-940 264 -908 961
-975 89 971 765
992 532 870 459
74 -34 -973 629
205 88 -595 200
315 -813 -571 -49
665 -102 354 -718
971 598 -606 -970
-138 -514 548 -556
132 518 766 123
50 635 -862 681
-400 -835 309 362
254 715 -881 -432
459...

output:

13

result:

ok single line: '13'

Test #71:

score: 0
Accepted
time: 22ms
memory: 29868kb

input:

100 982 314 572 741
827 -341 -377 735
407 354 -315 -387
623 926 -275 407
-754 299 53 -226
811 802 -377 -559
-922 -304 -372 -230
-96 96 719 -558
967 290 740 350
506 920 84 -87
-170 770 83 -547
252 809 417 56
107 -531 830 -83
828 -990 -85 906
-737 543 -767 -276
-805 952 166 -839
-202 -538 512 862
-619...

output:

2

result:

ok single line: '2'

Test #72:

score: 0
Accepted
time: 14ms
memory: 30916kb

input:

100 -391 -605 -114 115
-158 333 -696 -430
-482 64 850 530
-792 -702 632 -802
680 -62 424 220
-301 -711 168 781
202 -501 -151 -276
-7 272 -47 159
667 396 832 -935
-715 -865 -365 -639
199 -515 891 -36
-660 522 -281 -981
-983 -857 239 -284
-568 964 -504 191
-538 -97 473 12
-826 983 729 398
379 560 463 ...

output:

18

result:

ok single line: '18'

Test #73:

score: 0
Accepted
time: 13ms
memory: 28784kb

input:

100 289 -945 891 229
-911 883 237 -59
269 236 -6 -279
553 117 1 948
-193 936 519 28
310 -793 793 -480
-24 -318 -883 -301
-140 -291 223 -851
-236 -329 -65 -147
-447 730 352 380
-35 903 -900 -483
20 101 -979 384
36 98 -589 903
-138 761 980 395
-557 654 651 -140
-638 -126 -434 127
102 502 980 212
231 -...

output:

1

result:

ok single line: '1'

Test #74:

score: 0
Accepted
time: 11ms
memory: 29296kb

input:

100 -563 760 -885 991
602 -265 645 596
142 -397 252 -46
807 -794 528 -810
-582 502 516 -46
590 99 -501 332
753 -67 383 -817
932 -596 572 -632
-837 688 916 765
-578 560 361 122
-838 -831 -925 969
-625 603 717 -649
105 232 305 -749
889 361 583 641
-706 -478 382 -775
-74 -47 -850 90
-360 -935 -146 63
6...

output:

0

result:

ok single line: '0'

Test #75:

score: 0
Accepted
time: 15ms
memory: 31164kb

input:

100 -242 371 -878 335
123 -327 -7 -304
840 -442 292 331
-471 -319 805 -421
252 1000 567 167
-369 -472 -445 -65
745 -910 -335 -447
-9 771 872 306
141 994 -360 821
-777 633 -483 -937
749 809 394 -723
-953 198 -587 299
197 980 -977 386
-936 -422 878 809
-331 -901 919 660
871 347 -477 -432
340 163 -611 ...

output:

5

result:

ok single line: '5'

Test #76:

score: 0
Accepted
time: 16ms
memory: 30064kb

input:

100 191 437 -429 -643
-555 516 71 -912
120 -53 -113 162
-245 -737 214 -167
680 321 888 481
-595 152 -363 248
-143 791 -903 -946
-464 -338 -739 727
-902 -168 642 -899
906 -288 -811 25
216 76 744 971
-104 -43 -197 -425
835 -753 614 797
399 -750 44 -744
598 -301 868 -867
361 -872 418 16
-40 59 117 -135...

output:

11

result:

ok single line: '11'

Test #77:

score: 0
Accepted
time: 16ms
memory: 30448kb

input:

100 490 571 -146 -401
-489 732 143 841
969 -284 -142 -395
-900 243 -399 -649
956 981 319 -228
-112 -854 -246 645
-149 336 950 -877
795 970 450 -159
541 -697 -3 -949
592 697 449 560
971 -694 -836 -930
106 -677 980 61
-697 -145 833 191
-442 -856 -608 409
480 899 89 -168
869 -462 230 409
-601 785 17 99...

output:

9

result:

ok single line: '9'

Test #78:

score: 0
Accepted
time: 19ms
memory: 30084kb

input:

100 552 449 -447 -131
-460 -891 833 -701
-383 -877 834 -772
-945 -850 -160 464
-587 -287 -348 571
378 481 -169 848
-131 -618 -238 850
-363 614 -357 -812
-380 196 57 -283
306 -111 17 923
-431 -150 709 -376
-442 -452 645 -29
-182 -703 -902 -805
335 -514 601 -797
-575 -638 610 62
976 -748 250 -405
449 ...

output:

10

result:

ok single line: '10'

Test #79:

score: 0
Accepted
time: 17ms
memory: 29844kb

input:

100 376 595 843 915
-377 40 -860 -902
609 734 -643 440
976 334 689 -371
-516 768 286 -494
93 50 -640 378
225 -638 -758 700
-458 -112 480 918
-518 -121 389 -338
476 86 -240 -358
-181 -326 -919 -648
-992 327 -462 -508
94 824 -1 745
-569 -84 122 656
278 -79 -88 821
809 949 295 848
-173 -316 -491 861
77...

output:

1

result:

ok single line: '1'

Test #80:

score: 0
Accepted
time: 17ms
memory: 30064kb

input:

100 -578 -16 -346 933
-753 445 38 749
-104 -849 523 -606
-893 743 -367 -169
-158 276 -96 -797
-654 -300 -592 158
267 197 -286 -249
325 -666 958 304
318 -389 236 122
-945 -727 -130 -492
-576 950 -97 -911
249 536 -523 -909
-189 -62 -706 -286
638 -741 873 -539
456 -857 -231 -220
-523 -274 641 352
-106 ...

output:

5

result:

ok single line: '5'