QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#859495#9676. Ancestorslfxxx17 1734ms42088kbC++173.3kb2025-01-17 19:49:342025-01-17 19:49:44

Judging History

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

  • [2025-01-17 19:49:44]
  • 评测
  • 测评结果:17
  • 用时:1734ms
  • 内存:42088kb
  • [2025-01-17 19:49:34]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
bool be;
constexpr int N = 1e5 + 5, Q = 1e6 + 5;
int n, m, b, rt, fa[N], dfn[N], dep[N], cnt, st[N][17], p[N], in[N], pre[N], nxt[N], ans[Q];
vector<int>e[N];
struct Query {
	int l, r, x, id;
}q[Q];
struct ds {
	int a[N], sum[350], in[N], b;
	void init()
	{
		b = sqrt(n);
		for (int i = 1; i <= n; ++i) in[i] = (i + b - 1) / b;
	}
	void add(int x, int v)
	{
		a[x] += v;
		sum[in[x]] += v;
	}
	int query(int x)
	{
		int ans = 0;
		for (int i = 1; i < in[x]; ++i) ans += sum[i];
		for (int i = (in[x] - 1) * b + 1; i <= x; ++i) ans += a[i];
		return ans;
	}
}d;
void dfs(int u)
{
	dfn[u] = ++cnt;
	st[cnt][0] = fa[u];
	dep[u] = dep[fa[u]] + 1;
	for (int v : e[u]) {
		dfs(v);
	}
}
int get(int u, int v)
{
	return dfn[u] < dfn[v] ? u : v;
}
int LCA(int u, int v)
{
	if (u == v) return u;
	if (dfn[u] > dfn[v]) swap(u, v);
	int k = __lg(dfn[v] - dfn[u]);
	return get(st[dfn[u] + 1][k], st[dfn[v] - (1 << k) + 1][k]);
}
void work(int x, int y, int z)
{
	if (y == 0) return;
	if (x == 0 || dep[x] != dep[y]) d.add(dep[y], z);
	else d.add(dep[x] - dep[LCA(x, y)], z);
}
void del(int x)
{
	work(pre[x], x, -1);
	work(x, nxt[x], -1);
	work(pre[x], nxt[x], 1);
	pre[nxt[x]] = pre[x];
	nxt[pre[x]] = nxt[x];
}
void add(int x)
{
	work(pre[x], x, 1);
	work(x, nxt[x], 1);
	work(pre[x], nxt[x], -1);
	pre[nxt[x]] = x;
	nxt[pre[x]] = x;
}
bool en;
int main()
{
#ifdef IAKIOI
	cerr << (&be - &en) / 1024.0 / 1024 << " MB\n----------------------------" << endl;
	freopen("in.in", "r", stdin);
	// freopen("out.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		cin >> fa[i];
		if (fa[i] == 0) rt = i;
		else e[fa[i]].emplace_back(i);
	}
	dfs(rt);
	for (int j = 1; j <= __lg(n); ++j) {
		for (int i = 1; i + (1 << j) - 1 <= n; ++i) {
			st[i][j] = get(st[i][j - 1], st[i + (1 << (j - 1))][j - 1]);
		}
	}
	d.init();
	b = max(1, (int)(n / sqrt(m)));
	for (int i = 1; i <= n; ++i) {
		in[i] = (i + b - 1) / b;
	}
	iota(p + 1, p + 1 + n, 1);
	sort(p + 1, p + 1 + n, [](int x, int y) {
		if (dep[x] != dep[y]) return dep[x] < dep[y];
		return dfn[x] < dfn[y];
	});
	for (int i = 1; i <= n; ++i) {
		pre[p[i]] = p[i - 1];
		nxt[p[i]] = p[i + 1];
	}
	for (int i = 1; i <= m; ++i) {
		cin >> q[i].l >> q[i].r >> q[i].x;
		q[i].id = i;
	}
	sort(q + 1, q + 1 + m, [](Query a, Query b) {
		if (in[a.l] != in[b.l]) return a.l < b.l;
		return a.r > b.r;
	});
	int l = 0, r = -1;
	for (int i = 1; i <= m; ++i) {
		if (in[l] != in[q[i].l]) {
			while (r >= l) del(r--);
			pre[0] = nxt[0] = 0;
			for (int j = l; j <= n; ++j) pre[i] = nxt[i] = 0;
			l = (in[q[i].l] - 1) * b + 1;
			r = n;
			int lst = 0;
			for (int j = 1; j <= n; ++j) {
				if (l <= p[j] && p[j] <= r) {
					work(lst, p[j], 1);
					pre[p[j]] = lst;
					nxt[lst] = p[j];
					lst = p[j];
				}
			}
		}
		while (q[i].r < r) del(r--);
		int pl = l;
		while (q[i].l > l) del(l++);
		ans[q[i].id] = r - l + 1 - d.query(q[i].x);
		while (pl < l) add(--l);
	}
	for (int i = 1; i <= m; ++i) cout << ans[i] << '\n';
	return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 11
Accepted
time: 1ms
memory: 14064kb

input:

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

output:

2
1
3
3
1

result:

ok 5 number(s): "2 1 3 3 1"

Test #2:

score: 11
Accepted
time: 1ms
memory: 12060kb

input:

1000 1000
686 337 192 336 405 0 108 485 350 762 258 780 179 939 25 657 571 662 119 786 604 224 935 494 685 575 369 178 249 740 954 204 598 592 68 771 498 86 55 38 298 704 239 292 993 286 16 813 719 187 14 476 792 49 944 52 227 720 310 470 900 243 663 950 627 300 728 189 45 610 673 548 873 95 48 841 ...

output:

452
67
611
126
329
486
354
25
559
585
184
265
576
116
489
289
147
287
13
282
151
192
146
141
148
131
43
72
69
29
5
15
57
10
9
16
87
162
19
217
232
24
178
334
103
139
293
400
299
351
529
632
592
296
640
678
715
708
52
465
322
731
2
69
110
286
172
0
40
31
16
105
75
45
8
94
540
115
357
7
11
431
581
37
...

result:

ok 1000 numbers

Test #3:

score: 11
Accepted
time: 1ms
memory: 16040kb

input:

1000 1000
594 766 788 546 408 364 152 525 963 359 339 746 747 58 628 60 144 646 222 863 418 1000 494 84 225 21 202 146 81 879 239 526 662 816 483 140 7 834 978 26 370 619 12 112 824 319 855 852 877 32 708 236 296 791 40 102 238 930 734 609 740 309 982 837 272 451 825 977 717 597 761 90 305 224 216 8...

output:

441
362
300
535
197
383
360
29
428
31
473
9
310
242
232
37
96
227
50
146
180
93
108
83
58
106
61
26
61
32
7
25
54
25
59
17
48
42
68
237
83
95
206
339
161
47
377
250
335
136
436
98
6
515
216
132
263
270
137
463
117
292
61
468
237
326
149
0
126
228
353
168
76
332
169
98
75
418
49
133
284
281
282
134
1...

result:

ok 1000 numbers

Test #4:

score: 11
Accepted
time: 1ms
memory: 14096kb

input:

1000 1000
330 124 926 768 265 445 803 501 173 371 897 686 88 668 787 5 440 818 604 119 918 821 30 400 391 262 299 334 279 58 45 101 814 582 467 182 538 549 455 761 121 769 480 639 605 906 883 341 138 862 684 42 855 535 778 154 407 439 967 780 128 565 622 739 910 69 647 612 345 407 929 352 296 869 31...

output:

347
340
86
105
386
17
172
27
104
146
341
160
298
321
97
112
232
110
222
37
40
42
84
173
114
25
82
81
56
14
1
2
41
62
12
126
122
50
125
152
100
123
26
0
106
34
173
52
184
89
268
270
152
77
39
322
154
50
0
284
146
199
54
149
27
18
101
84
140
232
73
199
334
195
35
1
107
138
1
25
158
78
4
10
178
202
315...

result:

ok 1000 numbers

Test #5:

score: 11
Accepted
time: 1ms
memory: 9872kb

input:

1000 1000
461 631 908 871 9 818 589 859 917 846 415 498 899 405 954 857 192 327 912 204 453 253 923 705 211 775 882 41 956 634 761 588 676 694 428 729 575 747 216 979 10 472 471 422 580 944 295 121 62 603 376 520 720 864 792 22 891 773 77 520 801 680 590 70 617 807 784 136 566 699 167 726 75 701 780...

output:

95
177
33
70
54
125
39
35
0
263
17
65
55
46
144
73
55
152
58
145
194
103
68
101
34
32
83
60
43
24
0
1
23
46
51
114
57
27
116
38
86
70
53
52
147
129
136
46
41
14
137
154
161
159
205
6
149
157
21
24
7
50
81
9
15
53
13
134
225
36
32
3
104
44
73
139
35
24
191
94
61
128
399
29
103
2
31
34
23
116
9
91
158...

result:

ok 1000 numbers

Test #6:

score: 11
Accepted
time: 2ms
memory: 11936kb

input:

1000 1000
287 431 325 595 467 406 982 985 603 656 520 452 564 548 370 451 331 407 538 749 304 421 813 467 941 545 807 796 484 617 276 908 461 162 323 903 455 796 466 897 972 859 359 684 644 348 245 579 149 18 702 537 415 64 906 382 210 478 145 369 128 336 574 86 847 475 671 849 135 238 920 421 512 9...

output:

117
162
29
84
31
73
55
52
148
119
26
88
88
186
44
96
41
39
276
8
27
81
60
38
58
13
5
17
17
32
8
14
26
24
23
10
58
52
140
6
63
14
66
99
185
207
51
163
61
13
1
183
252
70
87
42
45
127
108
23
92
70
4
35
136
143
7
34
7
53
31
57
39
11
24
132
13
0
23
39
37
13
16
60
25
5
10
130
0
47
5
1
103
54
45
24
31
176...

result:

ok 1000 numbers

Test #7:

score: 0
Wrong Answer
time: 2ms
memory: 9868kb

input:

1000 1000
744 630 563 578 427 227 792 774 559 165 201 450 227 905 966 321 29 908 183 636 603 275 148 739 196 551 884 685 487 276 139 646 352 52 96 246 212 295 502 968 1000 938 121 100 326 309 567 582 744 290 170 312 464 262 768 179 921 741 4 431 107 465 240 973 526 369 172 744 580 420 134 566 875 85...

output:

65
71
39
51
42
31
29
29
3
25
170
6
3
38
58
97
9
11
65
3
27
29
136
24
108
67
83
54
38
13
0
11
58
22
33
17
6
5
50
96
75
13
60
32
239
165
20
49
16
69
73
280
98
29
341
67
25
21
46
69
101
65
12
134
81
3
61
10
5
4
42
46
23
88
39
153
96
55
14
31
1
3
48
57
42
4
24
95
41
68
13
24
20
0
9
28
190
53
35
79
68
10...

result:

wrong answer 82nd numbers differ - expected: '0', found: '3'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #30:

score: 0
Wrong Answer
time: 1734ms
memory: 24020kb

input:

50000 200000
42574 43129 47328 17982 40521 6668 12729 32377 201 11940 8599 11734 18349 41045 26854 22540 9897 33419 7463 1243 47272 27135 49050 49111 22435 42539 39924 20272 5843 9308 45963 3283 31185 13692 38952 20583 15885 24802 4773 953 49907 28689 36942 23550 19449 8970 33340 31665 5407 46023 18...

output:

12045
1321
12292
2444
32443
36534
38575
30505
16464
16648
47153
41144
23401
1762
18567
6831
26486
29716
8905
16295
38569
29990
22061
7638
3820
34754
17582
6466
12632
23384
11657
16493
24434
11503
3945
2205
37806
13036
29052
24114
39158
34702
37326
20815
11766
41253
44355
17807
23452
26717
43107
4133...

result:

wrong answer 116806th numbers differ - expected: '0', found: '530'

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 17
Accepted

Test #67:

score: 17
Accepted
time: 415ms
memory: 42088kb

input:

100000 1000000
6457 23693 90928 23592 90440 75018 16865 3342 83718 16731 95103 31510 38719 27886 29093 41955 6596 46409 51839 10527 91993 61074 14405 34833 53674 42363 11490 43757 46191 6058 59164 96938 57858 40178 97523 84164 21582 72243 11267 47368 97058 6637 95208 60092 53943 16441 28363 64965 52...

output:

52956
18767
1319
13405
11021
455
50595
81481
6813
3640
58937
10991
70
4713
36
9517
39731
1166
67346
74637
2667
45182
4914
6774
1625
4198
52270
30435
60137
48654
29768
2815
6846
73091
21944
49693
9923
46795
29787
6866
2435
20773
2959
34666
4377
2428
4582
7527
38292
7253
3586
63817
28075
43828
20215
1...

result:

ok 1000000 numbers

Test #68:

score: 17
Accepted
time: 402ms
memory: 40148kb

input:

100000 1000000
82160 95864 48267 17482 19568 35077 14202 20440 4649 64145 148 2227 6969 39096 36508 20991 67700 90300 69215 57284 18492 9246 9629 7538 7845 30368 55600 48445 18542 41242 45052 25380 20894 91677 77040 73134 15572 21966 25343 14501 16227 23870 39207 50024 30787 11148 16884 63700 33205 ...

output:

44469
16565
2546
424
43423
23219
20745
3045
35596
11249
3763
322
27634
52470
20391
28546
14538
26343
9739
15234
20199
4332
1072
43633
3512
1432
47918
11347
4284
9054
6824
9773
39448
19949
18592
16534
43419
3303
11308
51071
1613
30619
8351
15408
6155
28590
13050
10085
2851
15353
33854
11870
5231
3742...

result:

ok 1000000 numbers

Test #69:

score: 17
Accepted
time: 391ms
memory: 38832kb

input:

100000 1000000
25194 62545 57529 6618 90347 4663 56805 81144 16504 79307 43199 91078 67805 33396 46754 26525 75274 39333 20904 40286 76299 83579 79770 37838 8666 33691 40228 71445 16473 53091 68958 32037 72079 38640 89820 67042 68888 34997 65595 87669 425 95432 78811 30382 34738 51750 96653 87265 96...

output:

8417
8694
11361
18174
35962
18154
12865
15343
20557
3347
1471
13539
3932
8790
18648
6347
6750
15815
15254
27157
8688
2879
18
9789
18477
3458
17955
3648
11622
6554
6912
26184
14239
5131
9324
11512
12379
2347
2070
15793
33946
14861
30678
5093
21318
4920
2406
14339
13174
5540
8462
20728
32471
22062
151...

result:

ok 1000000 numbers

Test #70:

score: 17
Accepted
time: 370ms
memory: 38280kb

input:

100000 1000000
33869 32276 67595 11863 43366 78922 82984 33614 3349 89624 72004 26796 43181 99767 17557 34237 17402 67395 90333 32805 48065 18758 67335 51494 27849 40763 26396 34814 4622 83315 72679 97608 72899 60645 56697 71509 56066 31804 62175 73302 88129 16166 65481 42106 75805 6462 59931 64760 ...

output:

6810
8197
6684
8043
2294
1406
13501
366
6028
1200
11507
328
13178
3321
11894
9927
9616
6071
10736
21275
4465
5411
903
11738
2443
15750
6410
2417
17055
17971
18738
4022
604
14999
10200
2271
13714
14394
12211
2969
356
784
5710
7696
1207
14917
2663
13712
204
11649
17149
6685
1246
17528
1004
2737
19239
...

result:

ok 1000000 numbers

Test #71:

score: 17
Accepted
time: 356ms
memory: 37660kb

input:

100000 1000000
20202 95937 59388 22656 52438 32930 5034 5828 47736 1136 86325 30517 98060 3065 87038 7780 79252 23357 30657 39367 65318 82229 57604 36401 60931 35094 22631 8808 73815 59982 13375 6858 21054 24430 58627 54098 50600 60606 29357 14070 86046 26517 36726 52335 67979 76357 5601 23089 31084...

output:

8080
10613
4850
10949
1751
9724
3125
8953
7890
67
8939
9100
2555
3819
8351
6568
8400
5441
5389
7174
6213
192
9432
7100
8163
5061
301
2795
3245
1188
5631
2052
10101
6949
3562
3684
415
9990
9144
9728
6146
8696
9498
1323
2394
5737
7300
4857
230
205
2140
5777
10893
7591
7926
4528
10783
849
1105
4041
207...

result:

ok 1000000 numbers

Test #72:

score: 17
Accepted
time: 347ms
memory: 37504kb

input:

100000 1000000
32714 36692 31083 85620 49990 97881 7729 99744 40147 35697 60981 26710 5344 89140 82549 16186 23397 99781 1198 13479 97345 76067 11166 3816 31696 12712 86322 42387 91034 73311 30204 90186 10698 3027 90469 39773 32444 90557 38037 2811 1511 99399 82904 95751 88183 46088 2411 36754 55537...

output:

1651
603
4225
5306
397
1391
3536
2046
1766
490
4958
2050
4696
805
1761
2739
447
5839
4695
3436
4328
5745
3473
250
416
5155
4610
4209
1642
2759
33516
191
4150
227
2878
2211
1566
1426
4102
3894
862
5730
3712
284
2405
4794
1137
2228
1433
2714
3179
3730
5441
2064
1789
510
2117
3292
3637
5031
4231
123
18...

result:

ok 1000000 numbers

Test #73:

score: 17
Accepted
time: 351ms
memory: 37584kb

input:

100000 1000000
36665 34048 13767 33770 62077 34740 89600 80503 52776 40093 32294 4636 89965 40716 66459 28480 98172 65499 75307 50198 69522 69117 76142 43885 44253 95772 9808 24606 44782 232 53978 39817 47787 64598 64212 62212 95626 12362 43307 53664 69332 64445 43969 92373 79331 70902 8966 94532 70...

output:

172
2579
2057
370
587
357
2956
1810
2642
1698
1030
2438
1575
716
1289
465
290
746
251
544
2492
1082
1677
1712
140
358
2273
3595
1830
833
205
1282
1507
1036
2447
790
2637
1914
179
2660
1097
2213
3222
2898
2749
1224
1753
1913
1195
1034
2684
1729
1521
1823
2383
1378
992
2976
1018
173
947
1419
158
60
21...

result:

ok 1000000 numbers

Test #74:

score: 17
Accepted
time: 345ms
memory: 37360kb

input:

100000 1000000
25285 42985 85118 92894 42132 44140 53975 26689 61784 14964 16282 25047 75597 64954 5953 94806 31813 46882 99124 69274 16563 99491 48901 49282 93968 37463 87063 44721 80224 27813 69865 92499 37290 89151 9013 14686 53743 22181 97387 1651 98349 83530 72377 18130 14740 56916 51137 96409 ...

output:

559
2183
553
1868
835
705
969
689
758
913
1287
549
515
224
62
1326
98
22
1292
91
1349
1137
766
1376
1018
1264
412
504
1315
8326
1339
946
479
1370
666
824
1207
1283
1052
1248
483
279
616
713
1035
1238
267
454
232
520
63
729
989
935
459
925
1073
820
1258
806
582
876
952
1020
840
25
794
7954
476
532
13...

result:

ok 1000000 numbers

Test #75:

score: 17
Accepted
time: 338ms
memory: 37464kb

input:

100000 1000000
45641 92812 19273 534 22918 95339 49623 85082 11614 28980 94623 62966 94029 89417 32026 67387 21098 88461 79787 80579 70439 2237 33005 12097 54566 79993 8709 84315 71961 30427 71102 53068 64440 91069 37835 78768 69298 89753 74749 31675 88761 16128 30652 40027 61119 7929 58346 90950 46...

output:

47
261
531
247
546
126
413
382
501
311
450
420
449
5545
909
231
327
2383
3923
407
165
469
1004
244
2983
367
266
89
69
111
262
135
296
103
390
394
28
190
51
34
1023
652
275
257
94
5991
776
377
460
3
297
1097
267
865
84
132
1899
4363
568
1035
378
182
372
210
973
326
325
1096
308
412
1422
377
188
249
3...

result:

ok 1000000 numbers

Test #76:

score: 17
Accepted
time: 334ms
memory: 37308kb

input:

100000 1000000
27336 37910 97070 44183 29995 49758 375 48516 91840 91049 29697 89681 32833 2308 86559 61177 42205 96692 91604 2444 91144 27682 4676 99797 22019 16247 9417 50225 31431 70808 46328 50017 63524 5278 18670 63198 15944 74354 67677 93050 12088 76013 79026 55614 12339 14182 46310 13428 9916...

output:

1911
209
168
2145
1026
1117
1044
1328
1907
2396
1030
4802
256
1292
959
498
77
1994
129
37
546
320
3427
106
966
73
177
58
2261
27
243
3637
1085
45
45
988
104
3657
251
4347
115
770
3347
1269
584
4478
2780
2149
35
416
1042
687
279
4
405
2917
66
29
1673
90
8080
44929
87
1788
1107
0
762
570
135
313
19
11...

result:

ok 1000000 numbers

Test #77:

score: 17
Accepted
time: 325ms
memory: 37272kb

input:

100000 1000000
68832 32373 8416 96939 39398 89861 29491 80771 77258 91216 42470 36368 41607 85762 23748 83036 89913 79306 47521 95952 29390 20501 22320 61997 44162 1438 68695 60447 44225 2645 58263 31482 15544 53525 58961 27875 52303 33973 73625 90950 47618 59073 53737 73936 31350 51029 30325 80075 ...

output:

8749
2770
20977
309
7773
4348
416
1240
367
15
6011
1206
373
2668
1110
1366
1497
260
884
3545
2411
551
2031
5352
1775
830
6526
5956
508
2278
333
612
2206
2064
331
177
687
61
3358
1727
50
174
2120
864
540
3105
8855
691
40
23010
81
5080
284
8147
71
423
618
257
192
4583
193
2371
552
1332
2591
7580
6272
...

result:

ok 1000000 numbers

Test #78:

score: 17
Accepted
time: 299ms
memory: 37284kb

input:

100000 1000000
52596 92870 23336 2940 51422 3326 1167 15935 53574 32223 81209 78304 83774 19456 84269 63599 20409 59292 92654 72663 84426 54904 4555 97549 67958 6560 59682 2957 1954 73007 52716 10774 13088 65980 84260 82038 63214 89012 7045 57303 83156 65553 70535 26354 30036 41508 47950 98012 17904...

output:

11013
70
1613
1
26
344
3485
3395
91
662
17335
474
2066
10053
6183
2078
645
5732
2232
3205
1451
1647
12830
243
666
313
1831
1031
10313
393
76
1839
12266
1
1994
5955
116
1361
137
11
1057
216
281
23
3
1960
2940
347
3681
894
270
11
17
1350
336
3552
11336
1166
76
141
668
70
248
374
1941
4884
7
39
223
174...

result:

ok 1000000 numbers

Test #79:

score: 17
Accepted
time: 276ms
memory: 37508kb

input:

100000 1000000
15420 36295 57572 93259 99933 50829 54093 49401 5332 28155 61095 6514 9327 99477 79061 28414 68820 15733 72024 19460 5065 33104 7113 14199 89800 27727 75921 28069 31768 92999 25500 29175 23886 67063 57533 15833 99593 44538 18029 18572 88196 20223 30186 83539 27104 20858 40712 47967 63...

output:

44200
6310
7528
445
1189
1219
754
93
9088
1756
343
6512
566
22
21
29
17137
5903
809
283
5324
265
2556
10
2235
0
3495
4072
207
328
1803
511
315
23601
426
4
4539
9994
3302
296
4256
50
248
1901
575
4095
316
18938
14
351
17694
1
110
32
20517
9371
0
1420
2783
24046
39
2
2183
1683
19003
1979
2
2585
2110
1...

result:

ok 1000000 numbers

Test #80:

score: 17
Accepted
time: 271ms
memory: 37212kb

input:

100000 1000000
23007 79987 89085 99883 96890 99740 10510 70065 80644 86465 83082 10861 54100 56151 78066 41733 95343 6465 84266 14586 46762 77397 87648 73739 94595 23429 24847 79180 61005 67082 45153 34209 20140 13723 95468 17581 72087 15113 7465 83662 41715 23460 70251 68712 96312 25166 77212 72078...

output:

6775
1
200
19613
2913
4
12483
4
14392
28468
7570
0
11
10889
10923
1645
62
9854
2366
31
402
287
10162
390
16
10532
36
26536
13
0
41324
1
33
9348
3
42
5
3285
620
708
3591
521
1554
67
4016
8228
16130
12520
5945
2878
3
1
7645
72
12417
18127
116
18836
1037
235
558
2981
2513
8388
2
8095
4588
9184
0
21102
...

result:

ok 1000000 numbers

Test #81:

score: 17
Accepted
time: 275ms
memory: 37168kb

input:

100000 1000000
6874 55215 44688 21029 96008 42093 94483 28006 67048 63875 9543 95388 34487 7920 84724 67671 20513 28031 87091 60617 7163 70679 85227 57608 99709 40202 20309 50381 59016 40420 17856 98797 29758 48068 64406 93303 31058 62263 39898 8334 24046 61116 8489 48505 64262 21361 19110 13339 393...

output:

199
1
6
6
132
39
6
0
2
0
571
66
384
39
18
1385
0
20
24324
1
10282
5
18
9
27
0
7447
2
209
0
0
60162
22
4887
1
5
1886
13
207
4856
7354
12257
836
7611
273
1766
225
1
7960
1
1339
5296
3889
5
1
26
13
502
129
3930
1
22692
369
5
3
994
0
8890
4907
18
6765
14490
1430
13744
1341
60
11523
3
790
288
60
31328
14...

result:

ok 1000000 numbers

Test #82:

score: 17
Accepted
time: 271ms
memory: 37288kb

input:

100000 1000000
17834 22054 72610 46642 21637 53082 15264 47998 87761 76459 24702 54577 9644 44178 58830 36410 10000 35585 19346 38067 17765 12195 54569 45885 53340 54087 40382 63714 97632 63376 34408 39500 46514 67792 76734 65909 72776 52002 31732 58756 74778 43101 58065 54366 5773 40826 53405 30037...

output:

1
10267
1793
24537
26158
1
8883
612
1521
12251
2464
0
4653
24
302
59
33728
38156
11030
11263
3
12
23287
51
118
11058
1
1
3
412
3310
7
3
21
12
1316
5
2345
4
1386
3
12
3
3388
144
2527
1205
5
26
0
0
7
90
1127
660
34
11
37
332
628
981
1383
146
11214
1982
2
4
7489
1157
5339
103
1
3974
304
0
1569
37
56560...

result:

ok 1000000 numbers

Test #83:

score: 17
Accepted
time: 273ms
memory: 36968kb

input:

100000 1000000
59129 31244 44964 75131 93021 51917 34849 16168 68826 58861 47237 79237 53040 95035 55624 78434 88324 77851 67656 7423 68800 53112 5815 50841 72358 75439 832 42411 55132 93762 13270 15672 76428 81253 91794 93129 2423 94555 25851 71221 39036 1237 53352 48995 7590 10978 141 41199 5320 2...

output:

10979
1236
8193
17068
2
307
106
8
4057
179
3080
333
107
83
1
5213
107
5682
161
4110
12
9084
695
11
0
5
6694
28698
1
8
2
11992
945
1595
2244
1262
6000
238
11
3
17
19
1
52
4634
5
7
2
1795
94
22
1
17836
11
487
4528
8
0
22921
1631
28605
32897
2
6
6
22511
832
1
1
302
3
0
4
1
645
1
767
146
19890
8
0
1692
...

result:

ok 1000000 numbers

Test #84:

score: 17
Accepted
time: 271ms
memory: 37084kb

input:

100000 1000000
31208 41388 48444 11248 50934 86740 72386 44148 67070 46997 4751 51745 54547 41171 17747 36588 27750 66759 72664 91402 61748 82397 39043 63144 63459 55640 42600 34626 45571 39473 53454 10882 17685 51272 35736 23354 98093 1742 60914 11323 23605 21237 80538 70719 23363 90612 40619 7723 ...

output:

1
3600
70
2587
134
22
12442
17
3
27802
6571
17
23837
8
2
11722
6818
12
5
142
8
11688
36235
5
2018
0
5314
5
22
1044
1
14
8330
53
387
29
0
485
0
2407
27996
8654
448
2594
9901
9533
30
27
121
48
3
2
25834
193
43
0
303
1
12
7412
680
589
48
23
4
28
10110
1
14840
23853
5
3299
1390
434
42
4935
16
887
0
25
6...

result:

ok 1000000 numbers

Test #85:

score: 17
Accepted
time: 269ms
memory: 37008kb

input:

100000 1000000
62227 89636 44712 93145 33932 88276 27763 84017 25800 72311 49226 51030 817 3102 54075 15902 75228 93345 86323 2506 11489 83523 42726 28765 39741 49200 14168 35458 54019 72751 34838 45980 66810 57521 94015 25363 90960 4794 70534 18030 51977 22939 49713 61227 22724 32841 87983 65650 50...

output:

652
1
43
3
22153
256
56
9
572
21
15
1
423
6
18702
1126
2339
1132
25114
3
7573
6
16
1236
26658
466
226
9
2741
1395
9
7
580
14
213
4
702
35
12
4
633
11850
189
491
1651
3
48
497
437
15
1680
1390
10062
21
109
250
3
89
3
1
12
2410
3
422
205
1371
199
806
637
3
1
1
8196
1521
28146
21
133
15076
20
162
2
4
2...

result:

ok 1000000 numbers

Test #86:

score: 17
Accepted
time: 268ms
memory: 36836kb

input:

100000 1000000
72858 73980 88791 8425 71525 63657 1356 59804 82996 16120 26166 25414 68209 55611 31495 87701 4850 67695 73380 71084 97531 5808 39850 36342 65918 25977 63697 14493 81146 12191 35948 83263 81285 13612 29801 80982 84536 99665 33889 34386 14432 75661 43374 44075 29060 55876 21467 17337 8...

output:

6248
97
25000
3124
781
3
3123
0
12
49286
1562
12462
195
0
1
0
1524
97
97
390
49670
12477
97
6
5204
12237
6223
5914
12
6
195
195
6249
12
1
6250
3125
390
1562
195
12
48
195
1
3108
24916
11378
195
195
390
6249
390
390
12500
24787
48
6
693
3081
781
3
195
1
12
195
3
781
6
40297
6250
24
6
48
195
6249
3
30...

result:

ok 1000000 numbers

Subtask #6:

score: 0
Skipped

Dependency #1:

0%