QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#90616#5686. 种苹果ScintillaTL 5913ms110136kbC++145.1kb2023-03-24 07:56:222023-03-24 07:56:26

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-24 07:56:26]
  • 评测
  • 测评结果:TL
  • 用时:5913ms
  • 内存:110136kb
  • [2023-03-24 07:56:22]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define pb emplace_back
#define rep(i, s, e) for (int i = s; i <= e; ++i)
#define drep(i, s, e) for (int i = s; i >= e; --i)
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout)
#define pv(a) cout << #a << " = " << a << endl
#define pa(a, l, r) cout << #a " : "; rep(_, l, r) cout << a[_] << ' '; cout << endl

using ll = long long;
using vi = vector <int>;

const int N = 4e5 + 10;
const int M = 5e3 + 10;

int read() {
  int x = 0, f = 1; char c = getchar();
  for (; c < '0' || c > '9'; c = getchar()) if (c == '-') f = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - 48;
  return x * f;
}

mt19937_64 rng(0);
int Rand(int l, int r) {
  return l + rng() % (r - l + 1);
}

int n, cn, m, B, T, lstans, ans;
ll a[N];

set <int> se[N];
vi e[N];
int p[N], dfn[N], dn;
int cnt, col[N], top[M], len[M], id[300][100000], down[M];
ll laz[M];
double dep[N], mx[N];

void Link(int u, int v, int w) {
  a[++ cn] = w;
  se[u].erase(v), se[v].erase(u);
  se[u].insert(cn), se[cn].insert(u);
  se[v].insert(cn), se[cn].insert(v);
  if (p[u] == v) swap(u, v);
  p[v] = cn, p[cn] = u, dep[cn] = (dep[u] + dep[v]) / 2;
  int c = col[v];
  if (c) {
    col[cn] = c, a[cn] -= laz[c], id[c][len[c] + 1] = cn;
    rep(i, 1, len[c]) if (a[cn] <= a[id[c][i]]) {
      drep(j, len[c], i) id[c][j + 1] = id[c][j];
      id[c][i] = cn;
      break;
    }
    ++ len[c];
    rep(i, 1, len[c] - 1) {
      assert(a[id[c][i]] <= a[id[c][i + 1]]);
    }
  }
}

void Add(int u, int w) {
  a[++ cn] = w;
  se[u].insert(cn), se[cn].insert(u);
  p[cn] = u, dep[cn] = dep[u] + 1;
}


void Work(int u, int v, int w, int op) {
  function <void(int)> f, g;
  function <void(int, int)> h;
  auto ask = [&](int u) {
    return a[u] + laz[col[u]];
  } ;
  if (op == 3) {
    f = [&](int u) {
      a[u] += w;
    } ;
    g = [&](int c) {
      laz[c] += w;
    } ;
    h = [&](int u, int v) {
      static bool tag[N];
      int c = col[v];
      for (int w = v; w != u; w = p[w]) f(w), tag[w] = true;
      vector <int> sl, sr;
      drep(i, len[c], 1) {
        if (tag[id[c][i]]) sl.pb(id[c][i]);
        else sr.pb(id[c][i]);
      }
      rep(i, 1, len[c]) {
        if (!sr.size() || (sl.size() && a[sl.back()] <= a[sr.back()])) {
          id[c][i] = sl.back(), sl.pop_back();
        }
        else id[c][i] = sr.back(), sr.pop_back();
      }
      for (int w = v; w != u; w = p[w]) tag[w] = false;
    } ;
  }
  else {
    ans = 0;
    f = [&](int u) {
      ans += ask(u) >= w;
    } ;
    g = [&](int c) {
      int t = partition_point(id[c] + 1, id[c] + len[c] + 1, [&](int i) {
        return ask(i) < w;
      }) - id[c];
      ans += len[c] - t + 1;
    } ;
    h = [&](int u, int v) {
      for (int w = v; w != u; w = p[w]) f(w);
    } ;
  }
  while (!col[u] || !col[v]) {
    if (u == v) return f(u), void();
    if (col[u] || (!col[v] && dep[u] < dep[v])) swap(u, v);
    f(u), u = p[u];
  }
  while (col[u] != col[v]) {
    if (dep[top[col[u]]] < dep[top[col[v]]]) swap(u, v);
    int c = col[u];
    if (u == down[c]) g(c);
    else h(top[c], u);
    u = top[c];
  }
  if (dep[u] < dep[v]) swap(u, v);
  h(p[v], u);
}

void dfs0(int u, int fa) {
  p[u] = fa, mx[u] = dep[u] = dep[fa] + 1, dfn[u] = ++ dn;
  for (int v : e[u]) if (v != fa) {
    dfs0(v, u), mx[u] = max(mx[u], mx[v]);
  }
  if (u == 1 || (mx[u] - dep[u]) * B >= n) col[u] = ++ cnt, mx[u] = dep[u];
}

void dfs1(int u, int fa) {
  int son = 0;
  for (int v : e[u]) if (v != fa) {
    dfs1(v, u);
    if (col[v]) {
      if (col[u] || son) {
        if (!col[u]) col[u] = ++ cnt;
        top[col[son]] = top[col[v]] = u;
      }
      else son = v;
    }
  }
  if (!col[u]) col[u] = col[son];
  else down[col[u]] = u;
}

void rebuild() {
  n = cn, dn = 0;
  rep(c, 1, cnt) {
    rep(i, 1, len[c]) a[id[c][i]] += laz[c];
    len[c] = laz[c] = top[c] = down[c] = 0;
  }
  rep(i, 1, n) {
    p[i] = dfn[i] = dep[i] = col[i] = 0;
    e[i] = vi(se[i].begin(), se[i].end());
  }
  cnt = 0;
  dfs0(1, 0);
  dfs1(1, 0);
  rep(i, 1, n) if (col[i]) {
    id[col[i]][++ len[col[i]]] = i;
  }
  rep(c, 1, cnt) {
    sort(id[c] + 1, id[c] + len[c] + 1, [&](int i, int j) {
      return a[i] < a[j];
    });
    rep(i, 1, len[c]) assert(col[id[c][i]] == c);
  }
}

int main() {
  n = read(), m = read(), cn = n;
  B = sqrt(n / log2(n + 1));
  T = sqrt(n * log2(n + 1));
  rep(i, 1, n) a[i] = read();
  rep(i, 1, n - 1) {
    int u = read(), v = read();
    se[u].insert(v), se[v].insert(u);
  }
  for (int i = 1, j = 0; i <= m; ++ i) {
    if (!j) rebuild(), j = T;
    int op = read();
    if (op == 1) {
      -- j;
      int u = read() ^ lstans, v = read() ^ lstans, w = read() ^ lstans;
      Link(u, v, w);
    }
    else if (op == 2) {
      -- j;
      int u = read() ^ lstans, w = read() ^ lstans;
      Add(u, w);
    }
    else {
      int u = read() ^ lstans, v = read() ^ lstans, w = read() ^ lstans;
      Work(u, v, w, op);
      if (op == 4) printf("%d\n", lstans = ans);
    }
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 29ms
memory: 33268kb

input:

5000 5000
-1201801 4507224 -765313 5795451 -126649 -5052948 470601 -5571705 7680665 -2662502 -689392 -3195719 3416253 -1023134 -3112032 3810606 -6975732 712075 257599 -180764 5190759 177433 -6055975 1555412 7768627 3402404 -872471 -1311920 -4231370 117735 3172664 -1502849 -3929398 -90435 6955032 382...

output:

645
0
0
0
57
0
1665
1087
1455
73
1172
1094
0
1739
1202
1290
0
0
0
569
0
1532
0
358
337
437
0
567
1086
12
73
922
1024
183
25
0
0
0
979
4
3
7
162
305
1285
0
1185
0
1263
402
576
1284
0
0
832
908
0
422
1425
1268
12
0
1692
439
0
0
28
0
384
0
0
1079
1257
1149
541
642
133
966
406
0
0
848
1335
431
0
0
363
8...

result:

ok 1020 lines

Test #2:

score: 0
Accepted
time: 20ms
memory: 33264kb

input:

5000 5000
-994733 862196 -2643618 4810652 2000445 -712322 -3955371 2924820 -675771 -6848147 825176 -5612153 4757907 1475460 1043402 1647007 -1015110 2001651 -6330733 2969460 -815149 6241724 136943 2360333 -3204656 5569099 809569 -4081554 -178998 -1363975 -4486956 -1858705 -59824 845830 4381332 17942...

output:

1469
2442
2
0
35
1869
0
353
993
1572
1095
0
12
1458
0
1659
545
0
0
1243
0
0
1410
911
1701
1660
0
0
84
728
0
5
0
1031
2089
1108
524
225
1237
2233
3
43
1324
327
1085
1049
615
61
1840
1892
0
491
989
242
1058
965
625
0
2592
340
36
0
211
0
146
2168
46
0
227
0
0
0
8
2103
1334
0
23
128
0
0
1307
0
0
0
2280
...

result:

ok 962 lines

Test #3:

score: 0
Accepted
time: 27ms
memory: 33320kb

input:

5000 5000
1655881 -6171013 -6563069 6407036 -349214 1212406 2942912 -6594577 2008815 -1128329 -2115530 3807690 2938269 3705147 -5102093 -5658055 -2326373 4349357 -299635 825659 877457 3662152 358404 -892346 4685730 5257128 -6518733 -852709 4390588 -3492594 4680660 -386634 1743811 4770445 1735641 -39...

output:

1263
2159
0
107
4
2257
15
1329
172
0
929
0
1465
260
2106
496
685
80
347
1492
0
2638
409
0
177
0
0
0
5
0
2324
0
179
0
0
0
2122
1322
102
412
300
3
1272
0
6
0
1823
0
13
1739
1459
13
1207
278
0
1261
0
684
0
284
639
69
1700
88
243
1529
1970
0
98
2178
0
978
0
1229
1637
1620
660
835
0
0
214
953
203
674
159...

result:

ok 1055 lines

Test #4:

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

input:

5000 5000
1916330 -1277666 -2692038 -1686680 445447 522240 -9102533 4958411 5497747 -6470449 -1304451 -327692 -3951014 -5481922 -71181 -324109 -2416764 -6133434 -2713206 -6507719 -4562989 3531489 2232499 -1303696 3799685 1596321 4508356 -698966 6244189 -3451377 1146222 -1190263 -1224078 -1867687 256...

output:

0
0
0
1099
0
463
0
1182
25
0
784
0
663
1483
2171
0
1057
0
0
1377
0
0
0
218
0
0
70
906
1524
141
89
992
0
1667
0
308
0
77
6
0
148
0
1364
121
513
162
0
1440
1
1588
290
0
380
0
1517
8
1125
0
1362
592
74
0
83
443
857
0
0
0
10
307
1182
6
2352
15
953
31
966
2
536
2104
872
347
0
1846
185
146
1096
0
368
295
...

result:

ok 1023 lines

Test #5:

score: 0
Accepted
time: 1662ms
memory: 69456kb

input:

200000 200000
3962736 -7195878 -1853269 5312599 2123365 7028251 2312158 123258 -4443494 -5269322 877331 -616200 927434 -1927540 2943960 -7002528 -5869789 2362131 -2612652 -7859698 2076672 3520022 5147597 17824 -54033 5931665 -8193552 4202786 2726128 1137312 5233018 -580693 2414120 4925088 1642992 35...

output:

47152
78705
47731
29708
99910
0
62117
0
44783
61200
5955
2
46232
0
16545
1271
36509
0
90957
1856
0
84922
27751
45838
0
91943
2373
28623
1118
32482
0
3
63630
57801
81142
0
0
0
9458
0
34391
12206
9510
0
0
1284
92189
98017
23372
7
4783
38278
54827
0
0
0
65641
0
13882
16443
908
0
59951
44221
36623
0
897...

result:

ok 200000 lines

Test #6:

score: 0
Accepted
time: 1631ms
memory: 69388kb

input:

200000 200000
-268518 -732548 -901441 -4347722 -192409 4152660 -6078366 -412851 3364009 7704344 323003 -4336546 -1823880 -1675134 -4301206 1362880 -2495946 -7053206 -2570038 2259491 2394744 3832046 -4643805 2294419 -4484291 -7340794 382437 -1938061 4410387 2978726 52156 1753151 -7547313 -5689937 446...

output:

93379
79180
42500
0
34745
0
32820
0
79663
48221
0
3335
12767
0
0
45995
19496
58837
49719
0
642
887
72
0
0
22859
0
0
36154
19833
36991
990
75878
16314
0
21002
50417
81747
39036
34391
65298
0
0
32698
25301
0
39844
14215
8613
23554
79650
4124
25410
8590
60811
0
20040
0
0
52949
308
0
0
61800
22062
45239...

result:

ok 200000 lines

Test #7:

score: 0
Accepted
time: 1635ms
memory: 69464kb

input:

200000 200000
4471605 -2889587 2475793 4794555 5897977 866381 2062774 3733737 -2810691 -3123275 -1593937 543221 -3462221 6330012 -4003863 6366641 2045393 1616425 -6199720 8342761 -855613 -5496332 2625258 -1455774 -6907661 -3748453 -831288 1686462 -5278073 3138676 5730165 2039292 694348 -1314529 -173...

output:

0
421
0
0
9681
7022
7214
0
0
27527
0
31966
0
3457
68018
29401
0
0
55150
3666
3275
1874
30536
0
12447
41
35035
12705
0
5
13675
12373
0
0
52061
77962
1654
0
0
41006
6436
0
3624
3567
35984
66500
70
32054
0
21039
12570
0
0
0
19152
70428
12137
42842
0
0
0
2763
0
38788
43503
52273
6312
12519
86158
39300
0...

result:

ok 200000 lines

Test #8:

score: 0
Accepted
time: 1634ms
memory: 69588kb

input:

200000 200000
-890750 -1886888 4557806 -644020 494194 -2695808 2550714 4029509 1120191 -1432068 4947569 -861074 -5012051 3130809 5048423 2911722 3555406 -4902160 6599828 -5543160 4984807 -184407 -3457542 -7797283 -1069734 1904721 5103428 1063345 3476923 -1785030 4855156 -57227 -5334995 -2809093 2892...

output:

2
0
0
3040
0
28031
83220
20474
0
0
0
50236
95642
0
0
8070
0
117
0
893
2792
0
34697
79143
62228
47204
21758
0
30780
86096
5630
0
0
5183
0
30315
2222
21205
0
15214
24683
0
42490
11122
16553
0
19432
33366
0
28181
76378
13080
95166
4137
56659
2718
0
23634
16356
0
22985
42488
0
7949
0
44522
5532
0
6735
1...

result:

ok 200000 lines

Test #9:

score: 0
Accepted
time: 4324ms
memory: 92688kb

input:

200000 200000
-3731977 -2214890 -2655693 -4636219 1477879 -6652495 -6122932 -2086233 195642 -707975 -1089540 3930278 524808 653005 7012999 -4338192 -7000512 -4443331 338552 2677375 -9308411 -1663420 3989374 5517790 405209 -2349520 4825993 8728231 4180825 -762268 -5023792 -1018659 -4224802 4763633 -6...

output:

5229
34782
25115
2661
50096
0
39612
26827
0
28126
2078
0
0
34407
9531
0
0
20761
0
0
47962
9851
369
0
120138
0
2
93381
0
2660
26702
47790
0
0
26704
26895
81137
0
3679
0
45393
0
14777
41981
0
7090
71613
6156
20774
3562
0
282
655
7528
15837
3
29871
0
40192
28220
0
12640
0
0
0
0
50855
47380
1280
1829
39...

result:

ok 79940 lines

Test #10:

score: 0
Accepted
time: 4289ms
memory: 93032kb

input:

200000 200000
-40585 5100748 -7038081 1817391 1576827 5519684 1368666 4000857 -5019756 -494980 -2910690 -2921575 -1450894 4525332 2493608 587091 99422 3623730 949863 6943763 -4357327 -487234 193966 -3268630 233249 -9015969 -3500159 754246 -4918832 5886202 -713657 -1322141 112522 2407975 -2746873 -34...

output:

1353
0
0
209
0
0
16009
0
68984
117993
0
0
32215
68957
7843
0
0
337
73410
79683
14844
39
0
0
0
0
76874
0
25714
26698
0
38289
28839
86
49285
66274
60145
82238
0
39904
4
92114
9631
0
0
62293
8303
17952
82285
43896
22450
91265
0
0
0
55326
0
105788
15463
0
0
18382
23669
10732
0
100590
72128
105022
90996
...

result:

ok 79866 lines

Test #11:

score: 0
Accepted
time: 4578ms
memory: 94024kb

input:

200000 200000
-6113558 -5036394 7148216 6044286 1697972 -6261572 3196523 3345060 -286718 4103655 2590674 1667153 -4959092 -3950169 -2182382 -8223477 1542982 -8047223 -7405525 4648848 5070967 1656133 1203472 3343385 -7198801 -146934 3973197 -4115776 -685357 -3235680 458167 2397624 952393 -204466 6931...

output:

0
24700
0
0
20008
1966
62996
8367
60130
0
0
2
95563
0
0
52338
0
74984
0
44896
34982
38
52382
28147
0
1266
73006
0
3202
76011
73062
0
0
28518
0
6213
58369
1657
58891
0
0
57142
45478
24232
0
10783
0
37289
1214
0
61560
4422
23841
0
0
36444
59027
0
25949
14169
31928
6282
9668
64811
0
23074
84294
0
0
684...

result:

ok 79725 lines

Test #12:

score: 0
Accepted
time: 4347ms
memory: 92952kb

input:

200000 200000
-667019 3018428 617797 -513689 -4282503 2994016 199404 -548441 -9274627 -2760620 -3651286 8292075 -2556026 486189 1385575 -1696494 -331935 1997950 -521500 -953572 -223275 1658925 2092325 -6299249 -4340122 -3655956 2451585 1658576 1975826 7018293 -2439494 6477429 1250658 -3615349 266699...

output:

5
30050
0
0
64
43951
880
0
22989
86029
21880
17179
0
79761
6470
34232
5328
0
25318
9186
0
8396
19620
26638
17256
30875
0
3240
5253
86287
0
10585
9352
9200
4
17394
0
0
4
65427
19215
1177
36090
0
80250
0
0
79412
124148
0
43081
35212
48062
23736
18349
0
100011
1470
77104
46860
1989
0
4408
0
6559
0
9074...

result:

ok 79617 lines

Test #13:

score: 0
Accepted
time: 3056ms
memory: 84352kb

input:

200000 200000
1985164 309525 -2073939 5502869 -6074995 -7109331 -2645057 2635849 -647019 4959815 -7583310 1399462 -291124 -252462 -1985823 2255567 -6571018 -5537170 -125160 -1703040 -6965276 -3922287 -2504039 4762424 -906237 -2828723 565209 1381511 1060297 2834184 -5487607 9228972 -3224921 -2327543 ...

output:

99921
0
0
8019
88
1809
0
31208
15465
0
0
0
1401
0
0
30569
30174
33756
0
0
2750
0
0
3688
69265
88946
46964
0
61957
30471
0
4
11266
0
0
0
0
0
9422
0
0
66396
0
14741
23582
40014
31318
0
0
1083
0
0
61515
49064
16358
523
0
38748
38290
180
67271
52391
54610
88425
0
26072
2993
0
3
0
84480
0
221
81985
49641...

result:

ok 59876 lines

Test #14:

score: 0
Accepted
time: 3057ms
memory: 86656kb

input:

200000 200000
4875614 -2562679 -595766 1292442 -2111198 -356919 -5161742 1053473 2969712 -273633 -2531394 -1476904 4196610 -668689 5223226 2363388 -4749074 1453637 5172566 3098573 -6607553 3035344 9239499 3245836 8515152 5939773 -8006669 -1571201 2987555 2285896 -328166 8447115 8300141 4968943 -3553...

output:

0
0
34972
0
0
0
0
43716
0
5094
80848
0
0
11803
0
153
8247
349
22863
34888
4
46178
0
22091
19029
28735
63305
463
60599
44410
0
42798
0
21737
0
12846
5408
17461
41948
0
0
19273
0
94563
88252
0
75457
6882
1086
0
29281
0
14787
0
0
8704
1723
4723
41889
2473
71164
36950
0
0
58201
9
0
0
2111
7905
0
0
0
165...

result:

ok 59807 lines

Test #15:

score: 0
Accepted
time: 2981ms
memory: 86096kb

input:

200000 200000
8567007 -5226429 -2953979 247299 -1678504 -2081438 5564386 64495 5819388 -1707511 -2301065 4403497 -490222 6996074 -1035827 -3096248 -974733 -5496322 -1026076 164464 270319 6319804 3943329 1332077 5608709 -341708 2195141 3854122 4589360 -2638935 1302497 -6407416 -4772682 2652488 232211...

output:

0
6630
84215
0
0
12454
36522
0
20400
0
7425
0
12086
87353
25152
0
0
0
12970
12706
0
29863
25443
30543
33100
31334
9066
0
29065
0
8403
22000
58738
0
0
59561
0
0
7618
33455
15278
28182
81915
0
0
0
68627
0
0
38959
57160
49732
1554
37656
17318
0
39
26764
61115
22691
2148
72630
10895
4228
57426
40447
0
3...

result:

ok 59769 lines

Test #16:

score: 0
Accepted
time: 3978ms
memory: 109868kb

input:

200000 200000
-2424506 -2412587 375978 3903889 8078697 -6184291 3477404 2131469 -871 -4730294 531835 300684 -3322834 -121479 -4409421 -4332635 970753 8953808 3686560 1844489 -5025765 -508325 -1918502 -8746620 1027975 2735651 -5729629 2631941 4613862 826030 -1023189 -5287521 -2848446 1034127 2203986 ...

output:

26150
22136
0
30634
49445
2535
0
14848
0
0
166478
206018
7674
176
0
0
89413
0
73833
7206
34575
179574
52642
27887
0
134120
57825
16750
74616
121417
0
127063
55
7131
103582
0
0
26663
55389
128697
112435
21161
0
0
0
0
45280
0
0
54712
7600
112206
0
212602
16032
19005
105271
78179
0
0
16955
53039
0
2343...

result:

ok 40220 lines

Test #17:

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

input:

200000 200000
4157337 2051459 -2226442 -2859846 -1363238 3318798 -6086454 -2961180 5480585 -253878 -2198660 4422336 -1138307 6264707 -2662099 875139 -1532831 1526998 -1544412 1211341 1422737 859329 -995081 -759657 3803914 -200321 3640303 -858696 -9068385 -5597302 -1548498 -3046862 1840864 -7479957 2...

output:

13536
34482
0
0
55019
0
28302
84777
11433
186337
46112
17244
0
0
830
92517
0
122200
81940
137451
136677
148790
39062
0
44000
16973
49526
23770
78841
4408
0
0
11613
28718
0
0
30008
117773
174013
190054
0
38136
15010
68640
51254
2774
39397
74526
1874
0
136654
49924
0
46905
63671
16702
0
37421
4
0
4371...

result:

ok 39885 lines

Test #18:

score: 0
Accepted
time: 4010ms
memory: 109988kb

input:

200000 200000
-1944203 -4277932 1215473 -2549998 2964206 -1521691 -2377568 1677403 7157590 -156464 -6322029 1830838 3582053 7214339 -3080059 4031082 4258944 -858202 -737466 -203208 5352226 -6561338 1463355 6305121 4459725 46467 -4922472 3938727 -836994 -5595204 1293604 -722127 1049183 -386905 629972...

output:

128001
40881
0
94530
145226
193
0
0
26998
105006
115264
0
0
0
139243
142702
30991
0
0
56465
140392
81420
36795
0
71596
23044
32242
1030
0
0
26501
26555
28500
1488
230011
110993
308
0
173487
0
101032
1694
56453
67813
570
75772
101224
67002
23966
0
0
0
0
0
0
91992
0
0
0
0
100811
1275
0
50159
14120
315...

result:

ok 39992 lines

Test #19:

score: 0
Accepted
time: 5815ms
memory: 110136kb

input:

200000 200000
2020187 5752964 3729782 -3773575 -1227773 -4166269 -3406569 1132930 -2643694 -6039887 4782561 -1547560 -6441999 -4282759 262021 8264684 -2551868 6809020 -2692592 -2559467 8651479 527358 -5490633 2233287 1676764 3633016 895545 -1173517 -5880163 -2616915 -8857064 9434031 -4751149 998615 ...

output:

0
83556
56770
43620
5745
19259
0
0
0
22474
21122
148418
0
51167
51202
32151
0
5077
186593
17447
2193
6450
268
0
4102
20010
79701
70126
212837
0
0
28199
105781
0
93371
0
29459
0
0
42775
0
150313
0
35811
1590
44789
181583
56
0
0
110541
0
170694
223961
93470
23496
7603
152268
21799
83254
67
0
0
66107
1...

result:

ok 39809 lines

Test #20:

score: 0
Accepted
time: 5726ms
memory: 109860kb

input:

200000 200000
-5803732 -1015248 5033042 -4027966 -6335081 777716 5484060 6956103 5376739 -756548 -2111304 -297680 -3180617 -5018521 -803454 -1352740 372489 -2385092 -5557764 -1193567 -689952 -5080322 5863291 -1041878 -2543762 -2185503 1042196 1605817 5967643 5303210 -5871199 4217287 1513349 -1178448...

output:

44526
2979
0
144133
95614
101402
0
105709
362
21073
84972
0
128753
7979
0
2269
140679
9943
40477
133023
199178
316
10787
50107
64969
58248
677
0
0
20645
0
97788
0
14839
0
61195
81509
156373
14932
3054
4860
72727
0
63729
1786
11218
18503
3469
63859
61639
174282
100706
7627
0
10872
0
3241
0
91613
1052...

result:

ok 40037 lines

Test #21:

score: 0
Accepted
time: 5913ms
memory: 109884kb

input:

200000 200000
-262667 -1639231 -4099912 303606 -6035762 -242834 3420080 7049036 3392046 4240671 -1824766 4760436 3308771 1649215 -2530067 -2338543 1046789 2544361 -846843 -162281 623849 3870102 1624163 -5315221 5342309 -2981470 -5836301 6333766 -7968029 -3462116 689395 -133932 -5645666 -2945538 -451...

output:

32122
147410
0
114475
114
32502
0
26136
0
0
1809
0
108280
0
32277
48900
65834
21923
0
68189
1085
24004
3335
19242
0
9676
121214
4101
61849
3353
149163
43384
53395
5
129244
0
0
0
46732
4546
0
2890
104530
0
13737
0
0
0
68848
84053
98596
149937
133478
2562
13762
78310
4534
148161
36447
0
84955
0
16164
...

result:

ok 39899 lines

Test #22:

score: -100
Time Limit Exceeded

input:

200000 200000
1355855 -8231041 3957486 5457365 4940777 1471127 2629869 -2568612 3891882 2593904 -3670773 1274445 5817023 -7266326 -649453 563335 -2504295 4259024 986470 -3906577 4133241 3251208 2578032 5849055 5955528 3009124 437248 -9471234 -1846927 1332558 3010219 7997851 -1949622 2258304 260683 -...

output:

44097
0
0
789
3647
24533
0
9625
1606
766
0
0
98621
10032
80790
0
39117
25510
51453
20041
112174
4529
16319
4339
0
0
28496
0
16863
249
0
0
251
0
0
0
0
4682
0
19595
7420
0
0
0
42475
0
19366
46319
12766
0
100680
37403
596
5
709
10418
2339
73279
68326
32135
0
27174
60205
0
0
3
0
0
45100
0
0
0
0
0
2
0
59...

result: