QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#380771#7803. H-Shaped Figuresu2x1WA 161ms37144kbC++204.6kb2024-04-07 11:41:412024-04-07 11:41:41

Judging History

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

  • [2024-04-07 11:41:41]
  • 评测
  • 测评结果:WA
  • 用时:161ms
  • 内存:37144kb
  • [2024-04-07 11:41:41]
  • 提交

answer

#include "bits/stdc++.h"

#define all(x)   x.begin(), x.end()
#define NL       std::cout << '\n'

using lnt = long long;

const int inf = 0x3f3f3f3f;
const lnt linf = 1ll << 61;

const double eps = 1e-12;
int sgn(double x) { return (x < -eps ? -1 : x > eps); }

struct Pt { double x, y; };
Pt operator-(Pt a, Pt b) { return { a.x - b.x, a.y - b.y }; }
Pt operator+(Pt a, Pt b) { return { a.x + b.x, a.y + b.y }; }
Pt operator*(Pt a, double x) { return { a.x * x, a.y * x }; }
Pt operator/(Pt a, double x) { return { a.x / x, a.y / x }; }
double dot(Pt a, Pt b) { return a.x * b.x + a.y * b.y; }
double det(Pt a, Pt b) { return a.x * b.y - a.y * b.x; }
bool operator==(Pt a, Pt b) { return !sgn(dot(a-b, a-b)); }
bool operator<(Pt a, Pt b) { return det(a, b) > 0; }
double dis2(Pt a, Pt b) { return dot(a-b, a-b); }
double dis(Pt a, Pt b) { return std::sqrt(dis2(a, b)); }
double area(Pt a, Pt b, Pt c) { return std::abs(det(a - b, a - c)); }
bool onleft(Pt a, Pt b, Pt x) { return sgn(det(b-a, x-a)) > 0; }
Pt rot90(Pt a) { return {-a.y, a.x}; }
Pt unit(Pt a) {
  double d = dis(a, {0, 0});
  return sgn(d) ? a/d : Pt{0, 0};
}

struct Line { Pt s, t; };
double pt2line(Pt x, Line l) {
  if (l.s == l.t) { return dis(l.s, x); }
  return std::abs(det(x - l.s, x - l.t) / dis(l.s, l.t));
}
bool ptonline(Pt x, Line l) {
  if (l.s == l.t) { return sgn(dis2(l.s, x)) == 0; }
  return sgn(det(l.s - x, l.t - x)) == 0;
}
Pt intersect(Line a, Line b) {
  double v = det(a.t - a.s, b.s - a.s);
  double u = det(a.t - a.s, b.t - a.s);
  return (b.s * u - b.t * v) / (u - v);
}
bool para(Line a, Line b) { return !sgn(det(a.t - a.s, b.t - b.s)); }

struct Seg { Pt s, t; };
bool ptOnSeg(Pt x, Seg sg) {
  if (sg.s == sg.t) { return sgn(dis2(sg.s, x)) == 0; }
  if (sg.s == x || sg.t == x) { return false; }
  return sgn(det(sg.s - x, sg.t - x)) == 0 && sgn(dot(sg.s - x, sg.t - x)) <= 0;
}
double pt2Seg(Pt x, Seg sg) {
  if (sg.s == sg.t) { return dis(sg.s, x); }
  if (sgn(dot(sg.s - x, sg.t - sg.s)) * sgn(dot(sg.t - x, sg.t - sg.s)) <= 0) {
    return pt2line(x, {sg.s, sg.t});
  }
  return std::sqrt(std::min(dis2(sg.s, x), dis2(sg.t, x)));
}

struct BIT {
  std::vector<lnt> v; int n;

  BIT (int n) : v(n), n(n) { }

  void upd(int p, int x) {
    for (++p; p <= n; p += p & -p) {
      v[p-1] = (v[p-1] + x);
    }
  }

  lnt qry(int p) {
    lnt ret = 0;
    for (; p > 0; p -= p & -p) {
      ret = (ret + v[p-1]);
    }
    return ret;
  }
};

int main() {
  std::ios::sync_with_stdio(0), std::cin.tie(0);
  int t; std::cin >> t;
  while (t--) {
    int xp, yp, xq, yq; std::cin >> xp >> yp >> xq >> yq;
    Pt p = {xp, yp};
    Pt q = {xq, yq};
    int n; std::cin >> n;
    std::vector<Seg> v(n);
    for (int i = 0; i < n; ++i) {
      int x, y;
      std::cin >> x >> y;
      v[i].s = {x, y};
      std::cin >> x >> y;
      v[i].t = {x, y};
    }
    std::vector<Seg> lhs, rhs;
    for (int i = 0; i < n; ++i) {
      if (para({v[i].s, v[i].t}, {p, q})) { continue; }
      if (ptOnSeg(p, v[i])) { lhs.emplace_back(v[i]); }
      if (ptOnSeg(q, v[i])) { rhs.emplace_back(v[i]); }
    }
    lnt sub = 0;
    auto solve = [&]() -> void {
      std::vector<std::tuple<Pt, Pt, bool>> ps;
      for (auto [x, _] : lhs) { ps.emplace_back(x - p, x - q, 0); }
      for (auto [x, _] : rhs) { ps.emplace_back(x - p, x - q, 1); }
      std::vector<int> idx(ps.size()); std::iota(all(idx), 0);
      std::vector<int> rk(ps.size());
      std::sort(all(idx), [&](auto a, auto b) { return std::get<1>(ps[a]) < std::get<1>(ps[b]); });
      for (int i = 0, r = 0; i < ps.size(); ++i, ++r) {
        int j = i;
        for (j = i; j < ps.size() && sgn(det(std::get<1>(ps[idx[i]]), std::get<1>(ps[idx[j]]))) == 0; ++j) {
          rk[idx[j]] = r;
        }
        i = j-1;
      }
      
      std::sort(all(idx), [&](auto a, auto b) { return std::pair{ std::get<0>(ps[a]), std::get<2>(ps[a]) } < std::pair{ std::get<0>(ps[b]), std::get<2>(ps[b]) }; });
      BIT bit(ps.size());
      for (int i = 0; i < ssize(ps); ++i) {
        if (std::get<2>(ps[idx[i]]) == 0) {
          bit.upd(rk[idx[i]], 1);
        } else {
          sub += bit.qry(rk[idx[i]] + 1);
        }
      }
    };
    for (auto &x : lhs) { if (!onleft(x.s, x.t, q)) { std::swap(x.s, x.t); } }
    for (auto &x : rhs) { if (onleft(x.s, x.t, p)) { std::swap(x.s, x.t); } }
    solve();
    for (auto &x : lhs) { std::swap(x.s, x.t); }
    for (auto &x : rhs) { std::swap(x.s, x.t); }
    std::swap(p, q);
    std::swap(lhs, rhs);
    solve();
    std::cout << 1ll * ssize(lhs) * ssize(rhs) - sub; NL;
  }

  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

6

result:

ok 1 number(s): "6"

Test #2:

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

input:

1
-1 0 0 1
2
1 1 0 -1
1 1 0 1

output:

0

result:

ok 1 number(s): "0"

Test #3:

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

input:

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

output:

0

result:

ok 1 number(s): "0"

Test #4:

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

input:

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

output:

0
0
0
0
0
0
0
0
0
0

result:

ok 10 numbers

Test #5:

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

input:

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

output:

1
0
9
0
0
0
0
0
0
0

result:

ok 10 numbers

Test #6:

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

input:

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

output:

9
237
0
0
162
0
15
0
17
10

result:

ok 10 numbers

Test #7:

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

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 numbers

Test #8:

score: 0
Accepted
time: 39ms
memory: 3600kb

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 10000 numbers

Test #9:

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

input:

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

output:

0
0
3
0
1
0
0
0
0
0
0
0
0
0
0
3
4
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
2
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
2
0
0
0
2
0
0
0
2
0
0
1
0
0
0
0
0
0
2
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
21
0
0
0
6
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
1
0
8
0
0
0
0
0
4
2
0
0
0
0...

result:

ok 1000 numbers

Test #10:

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

input:

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

output:

2
2
69
67
0
0
0
60
6
0
110
0
8
3
57
17
78
3
0
67
0
0
131
2
494
0
0
108
0
31
28
78
0
228
0
2
4
14
23
325
52
0
25
0
0
59
602
12
135
52
193
0
5
123
19
13
36
41
17
0
0
165
0
4
28
81
0
0
22
8
4
2
0
7
7
3
0
0
0
0
4
3
0
0
6
0
0
0
9
0
6
0
122
274
0
1
569
0
314
0

result:

ok 100 numbers

Test #11:

score: 0
Accepted
time: 33ms
memory: 5872kb

input:

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

output:

1663
1999
246
1664
6624
2444
6071
1004
0
383

result:

ok 10 numbers

Test #12:

score: 0
Accepted
time: 32ms
memory: 9736kb

input:

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

output:

391283

result:

ok 1 number(s): "391283"

Test #13:

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

input:

100000
-30 -50 -15 42
2
54 -2 34 37
92 92 -67 67
-14 7 -60 -52
2
28 50 45 10
77 95 75 42
2 -30 -65 92
2
82 -73 -16 90
35 50 28 93
34 -27 -98 -84
2
85 72 -48 -82
0 14 23 63
51 -47 -29 -23
2
-31 -36 -47 13
25 -68 -24 8
-2 96 -50 -98
2
-94 -52 85 -65
-37 -46 24 19
41 -78 -92 -67
2
-11 27 9 -13
-82 39 5...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 numbers

Test #14:

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

input:

10000
-2 69 -8 -46
13
6 -35 95 -81
4 75 91 -3
67 -12 47 -97
7 -67 74 -22
76 95 -93 -67
-58 55 -51 -1
45 -44 33 37
-18 -84 18 -67
35 38 -31 83
-98 -10 99 -41
41 57 34 21
87 20 84 -30
25 -17 -42 -75
-87 -30 -74 18
9
-43 67 56 -28
72 -25 -5 98
-59 -33 21 -20
-7 -30 74 43
-41 -100 -5 -4
-88 77 -57 -68
2...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 10000 numbers

Test #15:

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

input:

1000
-30 1 19 44
146
13 -95 31 35
42 58 89 -5
-26 82 83 -31
-83 29 98 -39
-73 -91 86 -31
89 -75 -93 -12
85 34 -44 -84
-41 28 78 -20
97 -15 -27 16
35 -27 71 67
-68 58 -34 -66
99 18 56 88
-6 99 83 -13
44 87 -52 84
21 -94 64 25
34 79 -36 -21
72 -81 24 78
-92 44 -3 -92
37 76 -20 -90
95 70 49 -42
-11 -51...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000 numbers

Test #16:

score: 0
Accepted
time: 37ms
memory: 3928kb

input:

100
-96 22 57 73
3897
-11 24 21 67
51 54 32 11
95 22 80 -38
94 83 24 40
-35 55 -78 -2
13 90 18 99
81 -46 -63 -17
-69 -52 -7 69
93 -33 15 66
89 39 37 39
-39 -42 80 -21
78 -57 17 64
42 70 -49 -15
-2 -63 -12 -44
-50 23 -93 -53
51 -54 -89 75
98 58 -10 -85
-13 57 56 -78
-45 38 -98 84
-74 -50 96 -29
-82 1...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 100 numbers

Test #17:

score: 0
Accepted
time: 35ms
memory: 6440kb

input:

10
56 -60 18 -3
11606
-25 -82 -64 -95
-20 51 57 16
36 -36 92 65
91 -34 -94 61
-30 -19 -10 11
-54 -8 45 29
-93 -27 -98 -14
-76 -10 21 55
85 -35 74 73
85 47 -78 54
59 52 33 39
20 -89 -80 61
34 -22 -17 -2
70 35 47 -4
85 -62 -43 15
-71 88 18 -5
15 -41 64 -50
22 82 97 32
-61 63 -33 81
-75 40 -45 -93
-17 ...

output:

1
0
0
32
0
0
15
0
0
0

result:

ok 10 numbers

Test #18:

score: 0
Accepted
time: 39ms
memory: 9292kb

input:

1
-83 57 -15 37
200000
-89 -45 54 41
-86 -5 11 99
-6 -43 37 -12
3 23 -52 -44
23 59 -78 43
-31 -22 -15 97
100 9 -37 34
-30 -2 33 60
-86 22 -91 -72
-7 -57 7 90
-19 3 -84 -100
-83 -17 -82 57
-14 67 -79 93
-64 -91 -35 -41
-74 16 -94 -42
0 86 -85 16
68 -78 -16 -91
-93 -39 -58 57
60 2 53 -14
-11 -22 -13 2...

output:

180

result:

ok 1 number(s): "180"

Test #19:

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

input:

100000
19854 22803 72344 78974
2
92058 39829 64547 -68879
-8344 29238 -60161 -92335
80266 -1746 55811 -27168
2
4852 -75936 17429 -16082
-28331 -629 59177 5339
43242 88523 48964 -93729
2
6020 36584 -69470 -32480
62985 -30399 1657 -14554
21351 -72662 -3935 -7296
2
-48786 -82958 45773 -67728
-96794 -98...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 numbers

Test #20:

score: 0
Accepted
time: 48ms
memory: 9336kb

input:

1
-27969 51854 -41350 -18100
200000
37123 43400 -87468 75927
-4364 83045 78613 -66960
13392 -93810 41462 -69963
-85362 97766 4889 -33349
16277 86186 -77569 -85208
91033 -66776 -26886 -56098
18564 35677 -35224 45420
47017 -56641 -34505 -87030
-57757 4110 -7234 -29313
-34332 23932 3901 91091
73087 -77...

output:

0

result:

ok 1 number(s): "0"

Test #21:

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

input:

100000
-816084156 45345985 -809114376 38897510
2
-77832379 358421850 -316082520 -262180425
644176698 441808631 320726595 706144443
-845083578 178134515 -315798360 881807544
2
697452961 -634167100 -303275701 -967794117
173564593 -545926911 -868608924 828401067
667371571 -948204065 455255719 -52779314...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 numbers

Test #22:

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

input:

100
-951698201 -265293426 -657086404 -136559362
6786
573648106 -252912773 620242295 581457590
951580284 681897535 -817738867 -132231400
854299175 -599755614 -82485608 -89108261
400416421 -159940457 273451634 927897379
606472084 -664312828 297804033 -934818972
440036342 -699849074 -605129048 -9315978...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 100 numbers

Test #23:

score: 0
Accepted
time: 58ms
memory: 9332kb

input:

1
664476757 775661671 -460952714 -940529332
200000
602503004 -714067150 422736183 -916684357
638688933 -270306695 -595967030 142235971
-393400372 329594755 -384507397 468422405
-359113556 485787592 374594464 -417880421
-172028322 -765288212 -889383180 -474983301
-133547716 654038383 -291947477 -1958...

output:

0

result:

ok 1 number(s): "0"

Test #24:

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

input:

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

output:

2
3
120
212
191
1
211
253
131
3

result:

ok 10 numbers

Test #25:

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

input:

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

output:

14909
2441
49947
20028
6114
11554
130
3351
4258
442

result:

ok 10 numbers

Test #26:

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

input:

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

output:

109385
5676613
53957
304654
7795050
116240
98554
10578
46532
294962

result:

ok 10 numbers

Test #27:

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

input:

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

output:

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

result:

ok 100000 numbers

Test #28:

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

input:

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

output:

23
34
0
10
63
93
5
54
3
9
185
2
178
1
69
10
16
128
4
12
1
1508
4
15
0
17
1861
10
48
0
36
2
307
12
546
27
33
2
1
6
2
3
8
2
23
29
63
16
1216
142
599
20
39
1
4
469
48
77
8
16
8
7
26
33
16
10
94
25
85
218
7
431
177
41
1
908
170
127
40
363
6
0
37
153
9
12
64
6
2
2
429
1
19
4
6
19
129
3
3
14
14
229
42
108...

result:

ok 10000 numbers

Test #29:

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

input:

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

output:

5361
5828
5357
199
4085
3768
5453
15
12921
2375
844
16676
420
238
30322
27232
186511
3116
15
13987
395
2
7786
5331
19394
49
8214
33131
362
3595
0
1602
19179
3907
24
18
44294
66052
2761
610
12083
219
3367
899
2344
7368
1247
194
10427
203
4878
8
4514
718
91
11136
3356
12075
468
70145
63
658
379
9191
2...

result:

ok 1000 numbers

Test #30:

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

input:

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

output:

67559
1545601
398959
1050622
298157
38
468916
1571817
467329
8722
1501009
588
251558
32897
237449
288095
505815
6837
2264
299095
28446
1525
7005874
1514784
19536223
39442
217707
1630499
180340
518583
224522
2072468
68561
3972690
9950
7630483
37395
1128352
2370063
3533077
97659
1080
88977
2769
104575...

result:

ok 100 numbers

Test #31:

score: 0
Accepted
time: 90ms
memory: 10896kb

input:

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

output:

132022367
14030410
305084211
19676780
27608847
18594702
183120255
7344363
21053
9167933

result:

ok 10 numbers

Test #32:

score: 0
Accepted
time: 106ms
memory: 34776kb

input:

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

output:

9825159552

result:

ok 1 number(s): "9825159552"

Test #33:

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

input:

100000
-50 10 -29 -24
2
-12 -73 -88 93
-52 28 -48 -8
-16 23 -20 20
2
-93 66 61 -20
2 -30 -42 70
-41 11 -22 22
2
20 34 -64 10
-84 85 2 -63
22 10 -32 40
2
-29 -80 73 100
-47 13 -17 67
-20 5 39 37
2
13 -10 65 84
19 41 59 33
-32 -11 23 -47
2
31 -14 15 -80
-82 39 18 -61
40 15 7 -16
2
98 52 -84 -84
1 -94 ...

output:

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

result:

ok 100000 numbers

Test #34:

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

input:

10000
-22 38 17 9
13
54 85 -98 -9
-81 4 37 72
20 15 -64 61
7 -67 27 85
-27 -21 -17 97
38 -31 -4 49
-14 -25 48 43
41 57 -85 19
-41 79 -3 -3
-17 -42 51 60
60 87 -26 -69
-43 67 77 -49
-65 56 21 20
-22 -39 -43 46
9
-20 -7 -66 99
-57 41 -29 51
-5 -4 -39 -74
-54 94 -32 -2
-100 -82 56 4
-50 69 -36 23
-55 7...

output:

26
18
43
92
9
378
450
0
15
146
0
409
214
18
6
6
1
33
1
170
12
14
328
66
9
26
73
27
0
1
21
141
932
1555
44
226
757
183
78
30
15
286
117
106
40
347
0
0
4
0
10
26
7
283
1
8
262
18
39
95
6
461
180
7
298
101
73
208
84
12
3
2
2
24
12
47
12
4
50
957
2
13
53
3
107
20
0
101
13
679
5
1
18
50
0
72
104
1
0
359
...

result:

ok 10000 numbers

Test #35:

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

input:

1000
-24 2 50 -50
146
-50 37 2 -33
34 -44 66 -56
-100 43 52 -39
78 -20 22 -80
49 20 -97 -16
67 -68 33 -32
24 -46 76 -54
44 87 -92 -83
-24 -53 -24 57
79 -36 21 -64
60 -2 40 -98
49 -42 51 -58
-2 -61 -46 65
14 46 -62 -42
80 -57 20 -43
92 -86 8 -14
70 -69 30 -31
-68 83 20 -79
53 -41 47 -59
-92 -20 44 24...

output:

5128
265
3861
17458
46
1292
4450
742
695
6753
22
10935
111
165
135149
955
4687
918
12
1
100
13888
1158
33939
48606
1042
11871
170490
37507
122
3006
25618
1084
7165
689
82
26341
53
4873
584
281
21
703
997
562
5245
287
13125
840
184
3392
1358
25253
4328
98
6
6152
14520
1004
45
1627
2
79355
7539
22224
...

result:

ok 1000 numbers

Test #36:

score: 0
Accepted
time: 104ms
memory: 5148kb

input:

100
-18 -13 -10 -22
3897
60 -36 -96 10
40 -35 -60 -9
-61 -81 25 55
-63 -17 27 -9
10 53 -46 -79
-33 15 13 -59
-6 -39 -14 -5
37 39 -57 -83
42 70 -78 -96
-57 17 37 -61
-92 -70 56 44
-49 -15 13 -11
-52 -90 16 64
-44 -50 8 24
-67 46 31 -72
-10 -85 -26 59
-89 -57 53 31
38 -98 -58 54
-79 -82 43 56
-82 19 6...

output:

516346
52247
235660
7866
1261867
1550910
166258
1525247
1071904
446095
110705
105699
1154668
639252
13224449
211085
439831
50714
9382
36784
1232852
10688278
247237
426580
554198
34480
78817
89813
867916
12289
762938
12580
41751
6328
793
49261
642565
1583425
1661412
310065
6673
7931
30
778032
9913
22...

result:

ok 100 numbers

Test #37:

score: 0
Accepted
time: 114ms
memory: 18672kb

input:

10
13 42 21 -41
11606
70 12 -28 -94
-34 -94 76 12
2 93 24 -9
85 -35 -43 -47
-59 70 85 14
-22 -17 64 -65
-65 38 91 46
85 -62 -43 -20
13 60 13 24
-5 15 31 69
-29 76 55 8
-45 -93 87 11
70 69 -44 15
59 -81 -17 -1
96 -9 -70 93
48 -6 -6 -76
25 -83 17 1
-21 74 47 10
-56 -11 82 95
-63 28 89 56
44 -11 -2 -71...

output:

32989711
1982273
25739
1988570990
9454144
49432434
305399861
50674798
207826
14097434

result:

ok 10 numbers

Test #38:

score: 0
Accepted
time: 133ms
memory: 34480kb

input:

1
-13 -11 -5 -9
200000
-71 -35 61 17
41 -86 -67 64
56 -42 -82 20
3 23 -29 -45
-13 -24 -13 2
59 -78 -85 56
-90 -24 80 6
-37 34 27 -52
30 -11 -40 -7
60 -86 -70 68
-26 -28 16 10
-19 3 -7 -25
-82 -24 72 6
-17 -82 7 64
34 -8 -60 -14
-64 -91 38 69
43 -65 -53 47
16 -94 -26 76
-49 61 23 -83
-85 16 59 -38
28...

output:

887682699

result:

ok 1 number(s): "887682699"

Test #39:

score: 0
Accepted
time: 105ms
memory: 3644kb

input:

100000
41815 38439 10177 -13878
2
-12667 -1923 96297 78801
-629 59177 84259 17701
-35846 -25342 -10356 6739
2
4123 -33899 -24835 47377
-69470 -32480 48758 45958
33231 -35906 619 4356
2
52011 -52920 14451 -18892
31518 -73714 34944 1902
25668 10036 7285 9978
2
24488 -40809 -9918 60765
38511 -29066 -23...

output:

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

result:

ok 100000 numbers

Test #40:

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

input:

10000
-49135 -18234 -12117 -5496
11
61030 20169 -85264 -31161
-84533 -10067 -13737 -26401
-15272 -8564 -82998 -27904
-70286 -46965 -27984 10497
-12071 17742 -86199 -54210
-29235 -10088 5001 -904
23771 67493 -48005 -78485
-58232 -47487 -40038 11019
-62478 -750 -35792 -35718
-31894 -25572 7660 14580
-...

output:

20
0
915
49
30
5
383
248
24
369
12
56
115
3
72
159
149
304
2
15
0
0
513
155
22
33
152
168
4
0
2
1
18
1
12
11
204
557
281
12
17
168
0
44
477
7
112
135
3
25
140
40
0
56
49
43
5
1
38
0
0
74
14
103
99
2
10
11
0
33
29
31
35
2
6
697
1
95
5
2
31
17
23
0
416
2
1
0
12
97
2
8
0
59
33
24
87
126
116
2
22
232
46...

result:

ok 10000 numbers

Test #41:

score: 0
Accepted
time: 95ms
memory: 3740kb

input:

1000
3620 -7916 16564 23759
98
12481 -5481 20647 52999
50468 -29808 -17340 77326
-16265 36095 49393 11423
-20891 -74303 28131 58471
43112 -43367 -9984 90885
19030 -69326 -11790 53494
26275 79666 6853 -32148
-21340 1325 54468 46193
14560 -86904 -7320 71072
-19523 -50696 26763 34864
32331 38380 797 91...

output:

949
2139
1009
16416
111
2060
6759
5122
586
9663
10317
3
12019
2
53314
45629
2094
1
12536
675
2250
223
1271
506
6030
68882
5962
16172
737
2091
15735
89720
17791
23720
151
432
4259
335
340
5280
22
389
3428
23996
5709
22659
2301
1475
10354
10194
2164
2419
5847
17637
7149
21659
3350
16
526
17018
1023
39...

result:

ok 1000 numbers

Test #42:

score: 0
Accepted
time: 115ms
memory: 5356kb

input:

100
15416 32842 -49542 15299
1333
-147 -23353 -98937 53951
-36601 -32605 67433 98289
49660 55389 -18828 10295
1603 -9605 29229 75289
-93589 24536 -5495 6062
-81302 14124 -17782 16474
30716 13991 116 51693
-66540 -35773 -32544 66371
85006 36125 -54174 29559
-30227 -20610 61059 86294
-27150 47229 -719...

output:

362408
323543
74867
93954
758054
259960
4702675
616274
6848
350437
45914
65836
27615
35388
31677
1190
3420695
639013
95582
545890
143
13955573
1793498
58093
220808
35135
17262
3600
14558235
362131
7185783
30044
36895
2355768
49230
8233659
2033664
894513
730610
657140
13420
1925129
144136
512180
1201...

result:

ok 100 numbers

Test #43:

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

input:

10
47559 2806 -29653 -12256
37094
80548 95548 14570 -89936
-40852 -48857 -18454 24345
16136 35657 -75442 -60169
85300 -41789 9818 47401
70354 18614 24764 -13002
-62348 -62002 3042 37490
18667 84615 76451 -79003
-78534 8669 19228 -33181
39514 30793 55604 -25181
80111 -81061 15007 86673
35239 30963 -9...

output:

328750440
18006884
31523531
273434919
4166715
463133694
12844040
20773955
19463947
58319789

result:

ok 10 numbers

Test #44:

score: 0
Accepted
time: 158ms
memory: 34728kb

input:

1
39256 19564 -37380 -6
200000
-18599 -2254 -56161 2242
75927 -4364 2585 43492
6830 59664 -81590 -59676
13392 -93810 -88152 93798
-77243 80733 2483 -80745
97766 4889 -19254 34239
40589 37845 37923 1283
18564 35677 59948 3451
-87804 21223 13044 -21235
4110 -7234 74402 46362
-99382 18507 24622 -18519
...

output:

9580483377

result:

ok 1 number(s): "9580483377"

Test #45:

score: 0
Accepted
time: 128ms
memory: 3580kb

input:

100000
28369820 -225643654 -349099994 353809028
2
839622837 209531965 -782883197 -660819273
-262180425 644176698 -436019563 63441358
289768027 -380160569 85662899 178817814
2
201553894 -325831367 -30228096 683466995
697452961 -634167100 -117916907 -126154038
-484256727 402839011 391775763 156222045
...

output:

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

result:

ok 100000 numbers

Test #46:

score: 0
Accepted
time: 99ms
memory: 3960kb

input:

10000
326490399 302139981 -159618605 354027429
8
-410264657 113471284 91027447 594583574
-630824725 -124377025 311587515 832431883
-903612694 -113375010 584375484 821429868
-230419734 871131709 883400532 -266851747
358022724 463508886 294958074 140771076
28483179 781772461 624497619 -177492499
59208...

output:

8
88
131
50
28
43
984
19
0
555
450
62
3
2
160
6
63
52
31
266
2
12
83
273
68
0
61
22
3
0
0
4
1
352
52
7
13
242
47
2
9
75
3
135
147
30
10
11
7
118
1
65
95
52
54
41
283
0
7
414
17
1647
1
0
3
11
0
6
131
47
229
146
3
10
4
16
348
0
0
74
56
66
21
10
56
1
53
150
652
98
148
38
5
5
70
22
42
142
90
22
100
7
23...

result:

ok 10000 numbers

Test #47:

score: 0
Accepted
time: 109ms
memory: 3736kb

input:

1000
354360242 274554282 105633474 236793198
218
-694987972 986466168 906254920 -512879772
775843795 605391612 -67123311 -56283048
-353078271 563155020 564345219 -89568624
139422368 661219189 71844580 -187632793
195303592 -337942789 513416892 887051353
414052051 -6715870 -202785103 480302266
4902425...

output:

3823
1710
20924
28603
76
437
74
527
1890
16131
9411
89
272
529414
241
53407
64
1420
86
18132
23588
2113
12414
205
4
373
2713
30938
710
66
7268
1525
33
7942
2105
1793
8971
95710
1205
22926
598
100
5304
78
226471
3765
11428
708
1595
10152
5194
4602
19108
2310
13543
14
4485
698
24642
2092
1478
96
9728
...

result:

ok 1000 numbers

Test #48:

score: 0
Accepted
time: 122ms
memory: 5176kb

input:

100
-127401178 249974274 -32135029 90446042
6786
171741738 299147462 -426544094 200801086
581457590 951580284 -645727648 -770688200
-510126448 185166601 445856390 -4274517
-82485608 -89108261 -172316748 589056809
231175780 115225430 -485978136 384723118
927897379 606472084 -992167437 -425580000
-714...

output:

2398299
14263
582
625487
3605114
7673305
1357304
15474
18740
1905
5374172
184647
85440
1073
7223
111616
17227
7133
579618
3896
11716
997749
7883553
228897
5772833
205187
1317456
227449
7563491
41714
8964
1002295
115930
8941
1223961
419957
25088
18483
1
724444
24326
16022
1551226
334371
137234
974
70...

result:

ok 100 numbers

Test #49:

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

input:

10
50946621 -186773964 8687835 377058482
11986
609111239 550157411 -591735569 203959553
919622943 970431371 -902247273 -216314407
583201553 630066018 -565825883 124050946
424426862 336358752 -322533620 -709906680
-564146553 508063305 581522223 246053659
128755401 -84461863 -111379731 838578827
-6899...

output:

26348718
21126361
57781048
872377607
705860
296332831
11941322
26921541
49773143
23867

result:

ok 10 numbers

Test #50:

score: 0
Accepted
time: 161ms
memory: 37144kb

input:

1
341473953 290793476 272161379 121992083
200000
774393247 -348842833 -230070489 592826999
142235971 -393400372 540711935 974987324
355892054 -295241991 327055852 876828943
-133547716 654038383 816495622 -72451431
-145853633 -67120131 828801539 648707083
503452455 93381540 179495451 488205412
-17757...

output:

2294906324

result:

ok 1 number(s): "2294906324"

Test #51:

score: 0
Accepted
time: 93ms
memory: 3880kb

input:

100000
400000000 200000000 1000000000 900000000
2
200000000 300000000 600000000 -900000000
600000000 -300000000 700000000 -900000000
-500000000 -500000000 -800000000 900000000
2
1000000000 -1000000000 600000000 1000000000
200000000 400000000 -800000000 1000000000
-500000000 -100000000 800000000 -200...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 numbers

Test #52:

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

input:

10000
300000000 1000000000 -300000000 0
13
800000000 900000000 900000000 0
400000000 -300000000 200000000 500000000
300000000 -900000000 600000000 -200000000
0 800000000 200000000 -1000000000
100000000 -800000000 600000000 -100000000
-1000000000 -400000000 1000000000 500000000
-200000000 0 600000000...

output:

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

result:

ok 10000 numbers

Test #53:

score: 0
Accepted
time: 54ms
memory: 3760kb

input:

1000
-900000000 -1000000000 -500000000 -800000000
10
100000000 100000000 500000000 500000000
-600000000 1000000000 -1000000000 -700000000
1000000000 -700000000 500000000 -900000000
800000000 -1000000000 800000000 600000000
-500000000 -300000000 300000000 -200000000
-300000000 400000000 -500000000 80...

output:

0
0
0
0
0
0
0
4
0
0
3
0
0
0
0
0
0
0
0
0
0
10
1
0
0
3
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3
0
0
0
0
0
0
0
0
6
0
0
0
0
4
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
19
0
0
0
3
2
1
0
9
0
0
0
4
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
6
0
0
0
0
0
0
2
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000 numbers

Test #54:

score: 0
Accepted
time: 58ms
memory: 3868kb

input:

100
100000000 -700000000 600000000 -200000000
2515
-800000000 -600000000 800000000 -300000000
700000000 800000000 -700000000 -700000000
100000000 1000000000 700000000 1000000000
500000000 -300000000 -700000000 -200000000
-700000000 400000000 700000000 900000000
700000000 -800000000 -800000000 -60000...

output:

117
0
2
0
407
5
22
2
0
46
18
6
34
939
20
0
1
0
117
0
20
68
0
101
45
39
7
69
29
36
71
0
10
184
0
5
37
138
20
0
0
18
10
122
0
1
0
0
16
0
137
2
7
30
0
0
21
40
0
2
0
0
90
0
71
0
0
18
2
0
0
172
3
23
55
261
0
0
143
0
31
16
104
257
2
95
318
2
134
0
0
0
41
0
6
6
0
5
0
0

result:

ok 100 numbers

Test #55:

score: 0
Accepted
time: 58ms
memory: 6060kb

input:

10
1000000000 -200000000 700000000 500000000
38932
-700000000 -800000000 600000000 500000000
200000000 -400000000 -800000000 200000000
-500000000 -100000000 1000000000 700000000
700000000 0 -500000000 -600000000
-500000000 -700000000 700000000 1000000000
-900000000 -800000000 0 800000000
500000000 -...

output:

4218
2782
269
440
54
827
6707
855
18211
0

result:

ok 10 numbers

Test #56:

score: 0
Accepted
time: 55ms
memory: 9784kb

input:

1
-500000000 -700000000 100000000 -900000000
200000
700000000 -300000000 -400000000 -400000000
500000000 -400000000 -300000000 200000000
900000000 100000000 -100000000 -700000000
300000000 -900000000 -300000000 600000000
900000000 800000000 0 -1000000000
-1000000000 500000000 600000000 300000000
-40...

output:

133313

result:

ok 1 number(s): "133313"

Test #57:

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

input:

100000
-49326617 24331295 -6853588 -36141157
2
-131977828 -109534096 34854492 -11676844
41981200 20435579 -55688376 -92717893
31377094 -30090422 36502857 1842652
2
-154477753 -406717098 303875711 573826302
-44832633 -77389768 793474364 442903038
15122731 -44641234 6554787 -6498344
2
672567203 183068...

output:

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

result:

ok 100000 numbers

Test #58:

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

input:

1000
-15019221 -35830777 -17023813 -26332081
130
830008707 -436557825 -440540073 178780791
-397435645 -464230885 173182103 192617321
211732733 -171659032 -245780359 118994870
313810727 -211183261 -97226708 8007344
14420490 -11287274 -174245328 -101556116
253963483 -482606417 -183133411 243403998
-80...

output:

106
1381
23351
14
14686
997
8
3
311
21981
102
255
445
56
70
5010
2366
323
16382
253
53
14672
570
535
7587
601
636
9012
6256
76
24
3153
343
27
29
1841
173
167
7985
594
1
5479
39
7556
2900
10152
1133
15
107
753
888
1703
90
17593
715
4721
25
581
59
158
13766
8371
206
2783
470
155
328
406
366
693
1958
1...

result:

ok 1000 numbers

Test #59:

score: 0
Accepted
time: 137ms
memory: 11940kb

input:

10
34785288 49550135 1276713 -31563980
60518
66613269 -37774217 -85838695 -23283664
218181195 -104910676 -515402433 512932568
-961317600 -417548657 781862454 399874229
79589671 -94377501 -54823478 337405407
772909593 869810300 -770356167 -932938260
35059153 98714487 -32505727 -161842447
-74843426 73...

output:

240939845
2490672
610623
92706940
27003709
577548
53760091
366968
2587074
2738020

result:

ok 10 numbers

Test #60:

score: -100
Wrong Answer
time: 0ms
memory: 3632kb

input:

5
0 0 999999999 0
2
1000000000 999999999 -1000000000 -999999999
999999999 999999998 999999999 -999999998
0 0 999999998 0
2
999999999 1000000000 -999999999 -1000000000
999999998 999999999 999999998 -999999999
0 0 1 0
2
9 10 -9 -10
1 9 1 -9
1 1 999999999 0
2
1000000000 999999999 -1000000000 -999999999...

output:

0
0
0
0
0

result:

wrong answer 1st numbers differ - expected: '1', found: '0'