QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#102868#4909. 《关于因为与去年互测zjk撞题而不得不改题这回事》FISHER_35 1987ms511368kbC++142.7kb2023-05-03 19:14:412023-05-03 19:14:43

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-03 19:14:43]
  • 评测
  • 测评结果:35
  • 用时:1987ms
  • 内存:511368kb
  • [2023-05-03 19:14:41]
  • 提交

answer

#include <bits/stdc++.h>
#define fi first
#define se second
#define PB push_back
#define EB emplace_back
using namespace std;
typedef long long i64;
const int maxn = 1000000;
vector<int> g[maxn + 5];
i64 a[maxn + 5];
int dep[maxn + 5];
int siz[maxn + 5];
int son[maxn + 5];
int f[maxn + 5];
void dfs1(int u, int fa) {
	f[u] = fa;
	dep[u] = dep[fa] + 1;
	siz[u] = 1;
	for (int v : g[u]) {
		if (v == fa) continue;
		dfs1(v, u);
		siz[u] += siz[v];
		if (siz[v] > siz[son[u]]) son[u] = v;
	}
}
int tp[maxn + 5];
int id[maxn + 5], rnk[maxn + 5], stamp;
void dfs2(int u, int fa, int t) {
	tp[u] = t;
	rnk[id[u] = ++stamp] = u;
	if (son[u]) dfs2(son[u], u, t);
	for (int v : g[u])
		if (v != fa && v != son[u]) dfs2(v, u, v);
}
pair<i64, int> mx[maxn + 5][20];
int lg2[maxn + 5];
inline int queryMx(int l, int r) {
	int t = lg2[r - l + 1];
	return max(mx[l][t], mx[r - (1 << t) + 1][t]).se;
}
struct seg {
	int l, r, id;
	bool operator<(const seg& b) const {
		if (a[rnk[id]] == a[rnk[b.id]]) return id < b.id;
		return a[rnk[id]] > a[rnk[b.id]];
	}
};
set<seg> s;
inline void ins(int l, int r) { s.insert({l, r, queryMx(l, r)}); }
void init(int x, int y) {
	while (tp[x] != tp[y]) {
		if (dep[tp[x]] < dep[tp[y]]) swap(x, y);
		ins(id[tp[x]], id[x]);
		x = f[tp[x]];
	}
	if (dep[x] < dep[y]) swap(x, y);
	ins(id[y], id[x]);
}
i64 pop() {
	if (s.empty()) return 0;
	seg nw = *s.begin();
	s.erase(nw);
	if (nw.l < nw.id) ins(nw.l, nw.id - 1);
	if (nw.id < nw.r) ins(nw.id + 1, nw.r);
	return a[rnk[nw.id]];
}
inline bool get(i64 v, int w) { return (v >> w) & 1; }
int main() {
	int n, q;
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		g[u].PB(v), g[v].PB(u);
	}
	for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
	dfs1(1, 0), dfs2(1, 0, 1);
	for (int i = 2; i <= n; i++) lg2[i] = lg2[i >> 1] + 1;
	for (int i = n; i; i--) {
		mx[i][0] = {a[rnk[i]], i};
		for (int j = 1; i + (1 << j) - 1 <= n; j++) mx[i][j] = max(mx[i][j - 1], mx[i + (1 << (j - 1))][j - 1]);
	}
	scanf("%d", &q);
	i64 ans = 0;
	for (int i = 1; i <= q; i++) {
		int x, y, m;
		scanf("%d%d%d", &x, &y, &m);
		x = (x ^ ans) % n + 1, y = (y ^ ans) % n + 1;
		init(x, y);
		vector<i64> L;
		ans = 0;
		bool ed = 0;
		for (int j = 61; ~j; j--) {
			int c = 0;
			for (i64 o : L) c += get(o, j);
			while (c < m) {
				i64 o = pop();
				if ((o & ans) != ans) { ed = 1; break; }
				L.PB(o);
				if (get(o, j)) c++;
				else break;
			}
			if (c >= m) {
				vector<i64> nL; 
				for (i64 o : L)
					if (get(o, j)) nL.PB(o);
				L = nL;
				ans |= 1LL << j;
			}
		}
		printf("%lld\n", ans);
		s.clear();
	}
}

详细

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 1ms
memory: 28728kb

input:

931
184 700
485 184
419 485
386 419
308 386
114 308
301 114
598 301
120 598
144 120
595 144
812 595
236 812
7 236
543 7
327 543
858 327
68 858
177 68
398 177
899 398
408 899
848 408
202 848
269 202
304 269
540 304
647 540
672 647
314 672
157 314
241 157
745 241
300 745
343 300
92 343
117 92
30 117
2...

output:

1152921504606846976

result:

ok 1 number(s): "1152921504606846976"

Test #2:

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

input:

915
911 748
514 911
805 514
729 805
753 729
40 753
671 40
664 671
94 664
61 94
726 61
690 726
597 690
216 597
644 216
533 644
605 533
22 605
307 22
455 307
377 455
114 377
660 114
589 660
569 589
409 569
408 409
821 408
736 821
599 736
60 599
475 60
57 475
412 57
85 412
524 85
846 524
595 846
262 59...

output:

288230376151711752

result:

ok 1 number(s): "288230376151711752"

Test #3:

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

input:

930
111 896
637 111
559 637
289 559
103 289
759 103
341 759
605 341
778 605
154 778
169 154
721 169
631 721
741 631
750 741
344 750
641 344
639 641
769 639
48 769
389 48
25 389
70 25
508 70
185 508
199 185
602 199
89 602
473 89
565 473
373 565
865 373
867 865
658 867
271 658
685 271
269 685
317 269
...

output:

268435456

result:

ok 1 number(s): "268435456"

Test #4:

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

input:

948
537 716
933 537
605 933
563 605
801 563
860 801
19 860
717 19
908 717
820 908
885 820
693 885
69 693
263 69
129 263
295 129
880 295
303 880
12 303
299 12
1 299
421 1
312 421
720 312
100 720
438 100
380 438
386 380
223 386
627 223
293 627
387 293
709 387
193 709
640 193
906 640
34 906
405 34
790 ...

output:

1152921504606846976

result:

ok 1 number(s): "1152921504606846976"

Test #5:

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

input:

928
626 381
247 626
97 247
358 97
886 358
898 886
736 898
776 736
75 776
123 75
512 123
223 512
355 223
530 355
95 530
523 95
903 523
144 903
324 144
382 324
487 382
127 487
538 127
171 538
836 171
129 836
259 129
914 259
574 914
7 574
141 7
246 141
65 246
482 65
865 482
265 865
690 265
925 690
449 ...

output:

134217728

result:

ok 1 number(s): "134217728"

Test #6:

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

input:

941
87 448
396 87
398 396
623 398
837 623
234 837
896 234
258 896
700 258
52 700
27 52
515 27
308 515
774 308
76 774
21 76
753 21
493 753
902 493
878 902
58 878
146 58
342 146
414 342
312 414
621 312
88 621
460 88
683 460
150 683
845 150
535 845
467 535
326 467
247 326
280 247
474 280
124 474
22 124...

output:

1152921504606846976

result:

ok 1 number(s): "1152921504606846976"

Test #7:

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

input:

947
635 486
821 635
758 821
504 758
470 504
170 470
468 170
778 468
560 778
864 560
308 864
213 308
43 213
849 43
525 849
126 525
681 126
785 681
640 785
254 640
354 254
263 354
455 263
295 455
714 295
474 714
64 474
794 64
582 794
325 582
676 325
176 676
393 176
624 393
86 624
205 86
359 205
704 35...

output:

1152921504606846976

result:

ok 1 number(s): "1152921504606846976"

Test #8:

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

input:

920
889 920
64 889
647 64
482 647
798 482
368 798
593 368
169 593
788 169
469 788
59 469
71 59
611 71
779 611
675 779
272 675
703 272
237 703
525 237
485 525
483 485
266 483
160 266
302 160
321 302
697 321
82 697
516 82
817 516
428 817
857 428
23 857
319 23
918 319
359 918
749 359
681 749
849 681
33...

output:

4398046511104

result:

ok 1 number(s): "4398046511104"

Subtask #2:

score: 5
Accepted

Dependency #1:

100%
Accepted

Test #9:

score: 5
Accepted
time: 1500ms
memory: 27716kb

input:

949
158 116
73 158
131 73
252 131
596 252
9 596
488 9
555 488
828 555
150 828
388 150
586 388
903 586
24 903
405 24
746 405
321 746
48 321
588 48
431 588
225 431
299 225
325 299
593 325
516 593
829 516
369 829
775 369
90 775
610 90
45 610
793 45
745 793
859 745
422 859
342 422
91 342
773 91
32 773
4...

output:

4194304
2199023255552
288230376151711744
1152921504606846976
1152921504606846976
536870912
536870912
1152921504606846976
144115188075855872
576460752303423488
576460752303423488
2199023255552
2199023255552
1152921504606846976
128
1152921504606846976
1152921504606846976
0
70368744177664
0
11529215046...

result:

ok 100000 numbers

Test #10:

score: 0
Accepted
time: 1495ms
memory: 29444kb

input:

990
751 145
499 751
976 499
107 976
401 107
941 401
987 941
237 987
467 237
690 467
56 690
124 56
61 124
419 61
280 419
986 280
368 986
851 368
106 851
818 106
955 818
381 955
295 381
808 295
64 808
126 64
547 126
71 547
383 71
974 383
149 974
553 149
631 553
924 631
431 924
827 431
248 827
135 248
...

output:

68719476736
18014398509481984
35184372088832
1125899906842624
1152921504606846976
64
1152921504606846976
1152921504606846976
0
18014398509481984
32768
549755813888
1152921504606846976
1125899906842624
1125899906842624
2199023255552
144115188075855872
72057594037927936
1152921504606846976
0
115292150...

result:

ok 100000 numbers

Test #11:

score: 0
Accepted
time: 1556ms
memory: 32200kb

input:

941
145 851
347 145
164 347
242 164
298 242
666 298
877 666
624 877
130 624
161 130
133 161
251 133
917 251
629 917
598 629
277 598
370 277
63 370
32 63
502 32
457 502
791 457
455 791
719 455
331 719
478 331
578 478
387 578
46 387
547 46
685 547
213 685
518 213
364 518
369 364
212 369
870 212
417 87...

output:

18014398509481984
144115188075855872
1152921504606846976
1048576
576460752303423488
18014398509481984
8
2199023255552
128
2251799813685248
1152921504606846976
1152921504606846976
144115188075855872
1152921504606846976
144115188075855872
8589934592
18014398509481984
0
1152921504606846976
115292150460...

result:

ok 100000 numbers

Test #12:

score: 0
Accepted
time: 1472ms
memory: 29212kb

input:

922
594 757
328 594
297 328
199 297
285 199
724 285
591 724
42 591
560 42
195 560
367 195
372 367
107 372
160 107
708 160
85 708
32 85
441 32
14 441
528 14
820 528
97 820
34 97
527 34
27 527
65 27
23 65
572 23
387 572
277 387
259 277
211 259
482 211
635 482
244 635
182 244
147 182
674 147
135 674
92...

output:

1152921504606846976
562949953421312
128
36028797018963968
1152921504606846976
274877906944
1152921504606846976
1073741824
72057594037927936
17179869184
144115188075855872
36028797018963968
576460752303423488
1073741824
1152921504606846976
2147483648
36028797018963968
576460752303423488
1152921504606...

result:

ok 100000 numbers

Test #13:

score: 0
Accepted
time: 1498ms
memory: 31636kb

input:

968
323 906
42 323
767 42
750 767
645 750
19 645
617 19
834 617
588 834
807 588
428 807
244 428
606 244
787 606
777 787
654 777
10 654
89 10
693 89
920 693
947 920
497 947
125 497
526 125
923 526
612 923
530 612
214 530
403 214
651 403
785 651
696 785
836 696
69 836
883 69
177 883
87 177
899 87
623 ...

output:

576460752303423488
18014398509481984
288230376151711744
0
36028797018963968
33554432
576460752303423488
549755813888
9007199254740992
576460752303423488
1152921504606846976
72057594037927936
576460752303423488
576460752303423488
1152921504606846976
288230376151711744
1152921504606846976
576460752303...

result:

ok 100000 numbers

Test #14:

score: 0
Accepted
time: 1477ms
memory: 32316kb

input:

933
158 663
512 158
109 512
226 109
704 226
799 704
492 799
796 492
836 796
439 836
76 439
497 76
544 497
30 544
5 30
592 5
294 592
186 294
140 186
103 140
659 103
426 659
421 426
343 421
253 343
413 253
106 413
92 106
281 92
562 281
884 562
487 884
69 487
664 69
214 664
757 214
169 757
21 169
204 2...

output:

0
72057594037927936
288230376151711744
144115188075855872
8192
288230376151711744
576460752303423488
72057594037927936
576460752303423488
72057594037927936
1152921504606846976
68719476736
1152921504606846976
1152921504606846976
35184372088832
34359738368
562949953421312
576460752303423488
8192
87960...

result:

ok 100000 numbers

Test #15:

score: 0
Accepted
time: 1518ms
memory: 28836kb

input:

901
438 539
372 438
163 372
673 163
559 673
595 559
478 595
830 478
832 830
883 832
506 883
665 506
861 665
119 861
555 119
76 555
220 76
751 220
113 751
72 113
196 72
834 196
228 834
354 228
491 354
893 491
529 893
212 529
150 212
53 150
746 53
85 746
796 85
583 796
530 583
393 530
467 393
459 467
...

output:

576460752303423488
36028797018963968
0
1152921504606846976
36028797018963968
0
9007199254740992
72057594037927936
2199023255552
576460752303423488
144115188075855872
1152921504606846976
4096
35184372088832
1152921504606846976
35184372088832
1152921504606846976
1152921504606846976
2199023255552
11529...

result:

ok 100000 numbers

Test #16:

score: 0
Accepted
time: 1503ms
memory: 27692kb

input:

905
587 47
409 587
793 409
100 793
637 100
274 637
247 274
530 247
229 530
893 229
585 893
617 585
653 617
832 653
414 832
374 414
784 374
772 784
458 772
780 458
613 780
870 613
766 870
115 766
760 115
300 760
890 300
830 890
819 830
873 819
535 873
520 535
444 520
208 444
433 208
717 433
66 717
59...

output:

9007199254740992
72057594037927936
0
4398046511104
1152921504606846976
16384
1152921504606846976
72057594037927936
72057594037927936
1152921504606846976
281474976710656
1152921504606846976
72057594037927936
1152921504606846976
9007199254740992
9007199254740992
281474976710656
576460752303423488
1152...

result:

ok 100000 numbers

Subtask #3:

score: 10
Accepted

Test #17:

score: 10
Accepted
time: 70ms
memory: 76852kb

input:

99115
98506 98914
1961 98506
45808 1961
23027 45808
16655 23027
66393 16655
77250 66393
68284 77250
53684 68284
21189 53684
84955 21189
73464 84955
47574 73464
40651 47574
21101 40651
6589 21101
59680 6589
6185 59680
25529 6185
207 25529
33286 207
98459 33286
92565 98459
85446 92565
97388 85446
1630...

output:

2050

result:

ok 1 number(s): "2050"

Test #18:

score: 0
Accepted
time: 65ms
memory: 82280kb

input:

99546
79711 12863
50539 79711
13393 50539
27933 13393
13465 27933
79157 13465
53742 79157
51081 53742
32220 51081
21079 32220
85595 21079
50222 85595
14565 50222
4589 14565
13763 4589
58913 13763
93835 58913
34953 93835
2185 34953
10246 2185
64420 10246
44274 64420
63093 44274
8007 63093
85947 8007
...

output:

512

result:

ok 1 number(s): "512"

Test #19:

score: 0
Accepted
time: 61ms
memory: 81184kb

input:

99762
90013 76047
42293 90013
7801 42293
75274 7801
59320 75274
60896 59320
10435 60896
5384 10435
34648 5384
15596 34648
92041 15596
67457 92041
20760 67457
65611 20760
81462 65611
38984 81462
17583 38984
83787 17583
59980 83787
71477 59980
31143 71477
92168 31143
71205 92168
69348 71205
6111 69348...

output:

16386

result:

ok 1 number(s): "16386"

Test #20:

score: 0
Accepted
time: 69ms
memory: 76824kb

input:

99132
46469 40521
51811 46469
47968 51811
10584 47968
73 10584
27351 73
16693 27351
12495 16693
53425 12495
95973 53425
24901 95973
82771 24901
49155 82771
35995 49155
50432 35995
91209 50432
5781 91209
83457 5781
41361 83457
37973 41361
48829 37973
62896 48829
77593 62896
21307 77593
86547 21307
61...

output:

8194

result:

ok 1 number(s): "8194"

Test #21:

score: 0
Accepted
time: 81ms
memory: 79696kb

input:

99403
81802 91324
60321 81802
76749 60321
70097 76749
16085 70097
8301 16085
61886 8301
72994 61886
23906 72994
18815 23906
6781 18815
7774 6781
18318 7774
54769 18318
39330 54769
55677 39330
46758 55677
36164 46758
10159 36164
24678 10159
29603 24678
14941 29603
7966 14941
42934 7966
35909 42934
24...

output:

32770

result:

ok 1 number(s): "32770"

Test #22:

score: 0
Accepted
time: 67ms
memory: 82372kb

input:

99468
33859 68644
12306 33859
44304 12306
18200 44304
27325 18200
35907 27325
88149 35907
71599 88149
86384 71599
83793 86384
19513 83793
4843 19513
3007 4843
52878 3007
83019 52878
5275 83019
61517 5275
21453 61517
55993 21453
50710 55993
16211 50710
76061 16211
12048 76061
41970 12048
86181 41970
...

output:

514

result:

ok 1 number(s): "514"

Test #23:

score: 0
Accepted
time: 78ms
memory: 75592kb

input:

99179
45430 91876
8718 45430
75718 8718
15306 75718
21806 15306
78221 21806
74287 78221
66218 74287
66830 66218
64948 66830
16118 64948
33879 16118
81821 33879
69640 81821
27802 69640
25979 27802
6393 25979
63447 6393
48459 63447
53612 48459
27525 53612
52654 27525
80810 52654
767 80810
23808 767
82...

output:

32768

result:

ok 1 number(s): "32768"

Test #24:

score: 0
Accepted
time: 74ms
memory: 76244kb

input:

99240
8561 98467
49571 8561
13264 49571
94195 13264
85879 94195
53012 85879
29828 53012
25813 29828
57793 25813
10678 57793
88525 10678
70070 88525
54163 70070
51466 54163
3857 51466
77958 3857
29023 77958
154 29023
5173 154
4349 5173
24310 4349
21821 24310
36125 21821
75498 36125
7147 75498
22336 7...

output:

32770

result:

ok 1 number(s): "32770"

Subtask #4:

score: 0
Memory Limit Exceeded

Dependency #1:

100%
Accepted

Dependency #3:

100%
Accepted

Test #25:

score: 5
Accepted
time: 1063ms
memory: 511368kb

input:

992362
488995 967308
576776 488995
440373 576776
199494 440373
436524 199494
260014 436524
157103 260014
693611 157103
218612 693611
590935 218612
701779 590935
112004 701779
322594 112004
53706 322594
442686 53706
659639 442686
567880 659639
786210 567880
289019 786210
599273 289019
188834 599273
1...

output:

1152921504606846984

result:

ok 1 number(s): "1152921504606846984"

Test #26:

score: 0
Accepted
time: 1076ms
memory: 488676kb

input:

992770
411251 413303
421801 411251
751171 421801
294667 751171
506990 294667
136648 506990
288093 136648
514687 288093
886681 514687
75611 886681
178157 75611
99736 178157
277007 99736
744383 277007
226929 744383
53879 226929
617778 53879
170759 617778
467641 170759
123171 467641
732929 123171
90501...

output:

1152921504606847232

result:

ok 1 number(s): "1152921504606847232"

Test #27:

score: 0
Accepted
time: 1046ms
memory: 492912kb

input:

992506
78169 990749
904956 78169
8556 904956
618930 8556
318854 618930
643267 318854
255067 643267
635064 255067
911717 635064
932598 911717
323834 932598
620573 323834
172635 620573
541580 172635
96011 541580
745144 96011
403925 745144
60605 403925
118756 60605
219373 118756
253153 219373
30380 253...

output:

1152921504606846976

result:

ok 1 number(s): "1152921504606846976"

Test #28:

score: -5
Memory Limit Exceeded

input:

998381
898343 893428
759432 898343
531529 759432
497678 531529
960345 497678
211399 960345
268908 211399
804788 268908
48879 804788
567713 48879
934755 567713
587571 934755
2755 587571
357711 2755
312979 357711
758254 312979
494581 758254
906640 494581
80127 906640
558475 80127
694426 558475
34296 6...

output:


result:


Subtask #5:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #5:

0%

Subtask #7:

score: 15
Accepted

Test #45:

score: 15
Accepted
time: 1987ms
memory: 409848kb

input:

996678
2 1
3 1
4 1
5 1
6 3
7 5
8 5
9 5
10 7
11 8
12 9
13 1
14 2
15 7
16 4
17 5
18 17
19 16
20 2
21 1
22 1
23 9
24 17
25 19
26 10
27 9
28 7
29 25
30 25
31 4
32 11
33 31
34 21
35 13
36 19
37 25
38 10
39 11
40 20
41 35
42 1
43 19
44 20
45 41
46 1
47 19
48 5
49 28
50 21
51 33
52 7
53 14
54 21
55 20
56 1...

output:

4
0
4
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
8
0
0
0
0
16
0
0
4096
0
0
0
0
4096
0
0
0
0
2
0
0
0
0
4
0
0
0
0
32
64
0
0
0
512
64
4
4096
0
2
0
0
131072
0
0
0
0
0
0
0
0
2
0
0
0
2
0
4096
2
0
0
0
0
0
512
2
8
0
0
4096
64
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
512
0
0
36
0
0
0
0
0
0
0
64
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 99210 numbers

Test #46:

score: 0
Accepted
time: 1936ms
memory: 408272kb

input:

992539
2 1
3 1
4 3
5 2
6 3
7 1
8 1
9 4
10 7
11 1
12 5
13 5
14 4
15 7
16 7
17 9
18 12
19 5
20 15
21 1
22 13
23 6
24 4
25 7
26 21
27 23
28 11
29 7
30 23
31 16
32 4
33 25
34 12
35 27
36 34
37 1
38 3
39 1
40 4
41 16
42 4
43 19
44 1
45 29
46 5
47 15
48 13
49 1
50 26
51 46
52 8
53 9
54 1
55 47
56 26
57 31...

output:

0
0
4096
2
0
0
8
0
0
16
0
0
0
0
0
128
0
532
2
640
0
16384
514
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
2
0
0
2
0
128
0
0
0
2
0
0
2
0
128
0
0
0
0
132
2
0
0
0
0
128
0
4
0
0
0
0
0
16
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
32
0
0
0
0
0
0
0
0
128
0
256
0
0
0
0
0
0
0
0
16
2
0
2
0
0
0
264
0
0
0
0
0
0
0
0
0
2
0
0
4
5...

result:

ok 99668 numbers

Test #47:

score: 0
Accepted
time: 1938ms
memory: 407980kb

input:

991690
2 1
3 1
4 1
5 1
6 1
7 4
8 1
9 3
10 4
11 5
12 1
13 5
14 9
15 8
16 1
17 10
18 12
19 7
20 9
21 14
22 2
23 12
24 14
25 1
26 9
27 11
28 19
29 7
30 28
31 16
32 28
33 17
34 12
35 27
36 7
37 17
38 1
39 25
40 4
41 29
42 33
43 31
44 18
45 11
46 27
47 29
48 2
49 45
50 7
51 15
52 46
53 11
54 51
55 6
56 1...

output:

0
0
0
0
2
0
0
0
2
0
0
0
0
0
0
0
0
1024
0
0
0
256
0
2
0
0
131104
0
0
131104
2
0
1024
0
0
0
258
0
0
16388
0
0
0
256
0
0
0
0
2
2
0
32
0
0
0
16384
0
0
32
4
0
0
2
0
0
0
2
0
0
1026
8
0
8
4
0
4
2
0
0
0
0
0
1024
0
2
0
36
0
2
0
4
0
32
0
2
2
0
8192
0
0
0
0
0
0
0
4098
0
0
0
0
0
32
4098
1024
0
2
2
0
0
0
4
4096
...

result:

ok 99396 numbers

Test #48:

score: 0
Accepted
time: 1909ms
memory: 410016kb

input:

997182
2 1
3 1
4 2
5 1
6 5
7 1
8 2
9 5
10 1
11 6
12 3
13 5
14 3
15 11
16 1
17 9
18 2
19 1
20 7
21 5
22 2
23 15
24 13
25 21
26 1
27 2
28 3
29 19
30 20
31 4
32 19
33 16
34 23
35 13
36 13
37 14
38 33
39 13
40 25
41 15
42 32
43 34
44 40
45 13
46 41
47 46
48 32
49 29
50 39
51 2
52 16
53 41
54 3
55 7
56 1...

output:

0
0
0
0
0
0
4
0
4096
1024
0
4
0
16
64
8
0
0
0
0
1024
0
0
0
0
256
0
0
0
0
8192
0
0
1028
0
4
4
0
0
0
0
0
0
0
1024
0
0
0
16
0
0
2
0
0
0
0
0
0
0
4
0
64
4
0
524288
0
0
0
36
0
0
0
0
0
0
0
0
0
0
0
4096
1024
0
0
0
0
0
2
0
0
8
0
16
0
0
0
96
64
64
0
0
0
2
64
0
0
66
0
2
0
4096
0
0
0
2
64
0
0
0
0
2
0
0
256
0
0
...

result:

ok 99733 numbers

Subtask #8:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

0%