QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#103495#2063. Alternative AccountsQiulyAC ✓264ms3860kbC++142.0kb2023-05-06 08:19:442023-05-06 08:19:45

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
5 3
2 1 2
3 2 3 4
4 4 5 1 2

output:

4

result:

ok single line: '4'

Test #2:

score: 0
Accepted
time: 52ms
memory: 3640kb

input:

9893
25 1
19 14 10 6 23 11 18 16 8 13 24 5 22 20 3 4 21 19 17 1
15 1
14 15 3 13 8 5 7 2 6 12 1 4 14 11 10
25 1
21 20 7 11 25 15 9 18 2 14 19 5 8 17 21 12 24 6 4 13 1 16
23 1
18 5 15 12 2 17 3 21 14 1 4 6 18 20 7 13 16 22 9
3 1
3 1 2 3
4 1
2 3 2
2 1
1 2
43 1
13 28 14 16 6 30 17 19 18 10 29 22 3 25
54...

output:

19
14
21
18
3
2
1
13
3
5
40
2
25
61
34
22
38
34
12
26
62
71
9
17
23
51
10
68
38
15
34
9
76
40
45
8
7
88
37
51
22
7
6
60
40
11
24
1
58
1
16
6
56
15
91
6
11
42
27
1
6
19
76
8
10
1
74
11
25
48
5
20
28
45
10
18
82
16
1
5
6
2
79
58
26
40
3
10
77
36
74
14
5
23
11
59
4
7
42
15
29
66
26
24
14
4
8
15
13
22
1...

result:

ok 9893 lines

Test #3:

score: 0
Accepted
time: 237ms
memory: 3676kb

input:

90959
1 2
1 1
1 1
10 2
7 8 4 10 6 3 7 5
5 10 9 7 5 6
2 2
2 1 2
2 1 2
6 2
4 6 3 1 5
5 6 5 2 1 4
10 2
10 8 6 3 5 9 7 10 4 1 2
5 7 5 9 1 10
8 2
7 1 3 4 2 6 8 5
3 6 4 1
9 2
8 5 8 4 9 3 7 2 6
7 6 1 7 2 5 8 4
4 2
4 4 2 1 3
4 3 1 2 4
4 2
1 4
2 3 1
5 2
4 2 4 1 5
4 1 3 4 5
7 2
3 4 5 7
6 6 4 2 1 7 5
6 2
3 5 6...

output:

1
7
2
5
10
7
8
4
2
4
6
3
3
3
4
4
6
7
4
6
7
6
7
4
6
5
2
7
1
1
4
5
2
8
6
1
2
4
1
1
3
2
1
2
7
5
8
4
5
4
7
5
6
3
1
7
7
5
1
6
3
5
2
3
9
9
2
3
2
4
2
8
5
3
2
4
2
9
6
9
2
1
1
6
6
9
7
1
6
3
6
4
3
10
5
2
2
4
3
8
3
2
6
7
2
6
6
4
8
3
8
7
1
2
6
1
8
1
8
8
1
4
3
2
1
4
7
1
9
1
3
1
3
4
5
2
5
3
2
2
2
4
4
7
9
2
9
3
6
...

result:

ok 90959 lines

Test #4:

score: 0
Accepted
time: 87ms
memory: 3720kb

input:

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

output:

43
49
71
67
44
65
9
15
6
3
30
32
33
1
2
28
49
12
16
27
16
19
18
19
78
51
6
43
37
58
21
23
48
73
40
25
24
22
24
50
43
24
38
40
86
21
4
45
20
61
40
51
78
45
35
27
19
45
36
24
15
24
8
58
29
63
29
98
36
5
14
29
64
18
2
91
17
22
25
18
54
45
8
80
52
6
60
10
27
37
29
14
12
5
25
1
27
44
57
41
55
55
5
23
57
...

result:

ok 9904 lines

Test #5:

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

input:

997
637 2
624 325 544 88 42 608 245 328 17 22 631 458 153 179 38 623 511 198 587 543 213 91 580 203 610 281 222 578 317 368 224 550 284 255 215 172 473 2 507 583 29 26 560 178 416 413 449 613 418 157 225 472 626 170 194 272 238 81 455 607 239 567 199 131 84 97 299 619 513 230 533 164 559 385 505 532...

output:

624
215
66
208
975
209
569
22
600
187
29
616
337
372
87
228
378
181
104
300
276
55
445
149
398
956
430
454
411
614
703
162
435
854
299
283
651
635
510
329
221
35
341
381
6
193
43
487
283
13
88
571
144
377
203
132
190
43
430
185
431
308
122
618
327
117
213
181
527
690
713
347
911
52
756
513
205
214
2...

result:

ok 997 lines

Test #6:

score: 0
Accepted
time: 44ms
memory: 3712kb

input:

107
2115 2
349 249 737 32 1788 1720 1273 832 314 788 1522 35 535 714 685 1449 539 533 973 545 1093 1144 1798 1119 1465 728 1233 1503 815 908 718 82 207 1118 1886 741 1567 1651 1839 1709 1446 1030 1252 782 1891 1336 576 240 1497 1023 1254 148 1257 1442 113 541 1904 633 1692 780 109 1429 1589 1560 199...

output:

1589
3245
2380
4294
3985
7160
391
4025
6034
2859
3308
2800
2947
5602
3573
7306
1244
478
7393
4828
3957
6458
1137
605
578
4428
1709
894
4186
39
4240
4988
2029
1714
1138
3976
6919
1618
7253
3652
3413
677
1234
5896
664
4788
5657
3153
283
1492
186
4298
5576
4670
1196
210
978
3475
5042
4269
8061
4326
158...

result:

ok 107 lines

Test #7:

score: 0
Accepted
time: 228ms
memory: 3676kb

input:

91298
9 3
7 3 7 4 1 8 9 5
1 4
8 9 8 4 3 2 7 1 6
5 3
5 5 2 1 3 4
4 1 3 5 2
3 1 3 5
7 3
4 4 7 3 6
1 1
6 3 4 5 6 7 2
8 3
6 4 2 8 1 6 5
2 3 5
3 1 2 7
7 3
5 3 1 4 2 6
3 2 1 5
3 7 4 6
6 3
1 5
1 4
2 4 5
6 3
4 4 1 6 5
6 1 3 6 5 4 2
1 5
6 3
5 1 4 6 5 3
3 4 3 2
5 3 5 4 6 2
4 3
1 4
3 4 3 2
4 3 1 2 4
2 3
2 2 1
...

output:

8
5
6
6
5
2
6
5
4
2
2
10
3
3
6
5
6
4
5
3
9
3
6
7
3
2
4
3
4
4
8
2
7
2
5
10
3
4
8
6
3
6
2
7
5
5
7
3
6
4
4
1
1
4
2
5
7
6
6
3
6
9
9
5
7
4
8
8
1
4
6
4
8
7
7
8
3
8
1
4
1
9
6
1
2
4
1
3
2
6
4
1
5
1
4
2
3
7
1
10
6
2
9
3
5
6
7
4
4
4
1
4
3
4
4
4
7
5
6
2
8
10
5
2
1
2
5
3
3
5
4
7
3
2
5
1
5
1
7
1
3
5
5
1
5
2
4
4
...

result:

ok 91298 lines

Test #8:

score: 0
Accepted
time: 136ms
memory: 3720kb

input:

47586
19 3
11 4 6 1 16 5 15 18 10 14 3 11
14 3 6 7 8 4 5 9 10 13 12 16 18 17 19
16 17 2 10 15 8 6 9 7 11 12 3 5 16 19 14 1
18 3
18 16 10 13 7 1 14 2 17 5 15 3 4 12 6 18 11 9 8
13 18 4 16 13 9 3 1 5 7 11 10 17 6
7 9 6 13 7 15 5 2
9 3
3 5 9 8
2 9 2
3 3 7 1
2 3
1 1
1 2
1 1
4 3
4 1 3 4 2
2 2 4
4 4 3 2 1...

output:

17
18
3
1
4
4
3
12
10
4
3
7
4
14
15
8
5
7
6
6
3
6
13
4
5
9
17
19
12
12
3
5
3
7
7
20
15
13
14
10
5
10
5
5
12
6
2
4
1
4
5
4
18
10
2
7
15
11
12
5
13
17
10
15
12
6
10
4
17
4
10
16
6
5
11
4
10
6
17
8
7
18
10
5
15
1
1
13
10
4
1
3
11
1
2
7
14
7
14
6
6
7
15
13
11
8
14
16
8
18
13
3
13
12
3
11
5
4
4
19
16
8
4...

result:

ok 47586 lines

Test #9:

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

input:

9892
73 3
21 58 21 26 12 10 64 59 41 38 34 43 47 27 66 4 53 55 7 71 3 20
33 47 4 70 6 69 54 43 50 73 38 71 15 7 18 9 57 49 30 59 32 65 34 66 11 23 26 55 41 10 51 1 35 52
34 25 51 12 39 7 57 8 60 55 63 13 30 28 27 59 41 9 61 29 50 52 22 19 67 20 48 16 72 24 11 31 62 56 33
3 3
3 2 3 1
1 1
2 3 1
25 3
2...

output:

34
3
16
68
14
32
60
18
43
72
23
67
46
29
14
51
2
61
65
36
67
28
14
55
28
78
36
12
48
19
75
13
44
4
79
20
43
19
33
83
35
34
28
3
60
9
10
81
9
22
60
3
61
71
50
17
11
11
35
17
15
62
50
40
28
23
31
15
42
31
8
29
86
61
80
20
12
6
3
39
9
14
36
8
4
38
73
59
4
54
44
59
21
39
58
55
23
9
20
61
26
28
26
33
9
4...

result:

ok 9892 lines

Test #10:

score: 0
Accepted
time: 66ms
memory: 3728kb

input:

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

output:

54
456
301
75
393
239
706
22
391
544
97
184
291
528
655
500
304
188
881
267
55
759
40
39
573
196
716
769
717
673
213
471
486
220
341
253
152
583
490
753
614
210
220
159
2
271
50
543
518
730
844
301
319
292
222
653
822
216
385
87
49
259
365
901
204
628
351
311
426
655
234
568
740
578
833
592
658
618
...

result:

ok 984 lines

Test #11:

score: 0
Accepted
time: 56ms
memory: 3640kb

input:

95
8243 3
7716 4341 5782 6086 3440 7847 6224 1029 1108 3704 6024 6587 511 4255 3107 5474 984 6998 2729 1900 2644 18 4139 1780 7345 5744 4654 8208 3428 8237 6034 963 1723 4832 7672 3651 3612 6285 5483 7737 5751 1961 7111 8132 6414 5877 7147 286 2276 4029 4368 7392 7996 7781 3731 2107 2924 1142 7924 5...

output:

7716
2240
5818
2734
2955
5228
2819
2855
2093
3643
3356
6062
2159
3728
1511
5672
2927
6919
3874
5478
6283
2409
1833
2351
5216
3726
2361
8172
1991
5808
4402
5022
610
5786
3600
6338
1421
3761
1488
5796
5949
7303
9035
3419
959
1640
972
7706
7942
2159
6210
1246
5921
2353
3811
5299
7094
2015
908
4312
8393...

result:

ok 95 lines

Test #12:

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

input:

21
30716 3
12521 2410 4620 10518 21969 11969 11358 151 11399 14880 14848 25381 18354 25069 14590 10629 22632 27890 29104 209 21038 23922 27167 3687 29112 29685 20091 7673 2363 5824 14859 16998 20310 3518 27099 11272 17501 27259 26699 17189 28387 9391 13970 3366 16529 26135 28977 6812 819 4156 21316 ...

output:

19406
4981
4280
30799
23099
30453
3976
2555
6176
9456
6794
5349
15618
44243
583
12785
43774
20502
29065
13734
29488

result:

ok 21 lines

Test #13:

score: 0
Accepted
time: 264ms
memory: 3748kb

input:

91087
3 4
3 1 3 2
3 2 1 3
1 1
2 2 1
3 4
2 2 3
1 1
1 2
3 1 3 2
1 4
1 1
1 1
1 1
1 1
6 4
6 1 4 3 2 6 5
3 3 2 6
2 2 5
5 1 5 3 2 4
9 4
7 4 7 5 1 8 9 3
2 5 4
4 7 4 3 9
8 4 8 3 5 6 1 9 2
9 4
5 2 7 6 3 1
5 2 4 5 3 9
9 4 9 3 8 5 6 7 2 1
2 7 8
10 4
5 4 2 1 7 9
5 3 4 7 9 8
7 8 6 3 9 4 5 7
3 5 10 2
10 4
1 6
5 4...

output:

3
3
1
6
8
9
7
8
7
4
6
6
5
7
9
3
5
9
2
5
5
4
4
5
1
10
10
1
4
5
6
4
1
7
2
6
4
9
4
5
3
4
1
3
2
5
8
7
5
9
6
2
6
7
9
7
8
10
3
7
6
2
8
4
2
8
8
2
2
1
1
6
4
4
2
7
2
7
8
4
5
4
3
7
4
2
6
5
1
4
4
8
4
5
6
1
9
5
5
2
7
5
8
6
5
1
1
5
1
5
5
5
4
3
10
7
3
5
9
6
8
3
6
5
3
4
3
4
2
2
1
2
5
5
4
2
2
2
8
4
2
8
7
7
3
3
4
6
...

result:

ok 91087 lines

Test #14:

score: 0
Accepted
time: 234ms
memory: 3640kb

input:

62629
6 4
3 1 3 6
5 4 6 3 5 2
6 4 3 6 1 2 5
6 4 1 2 5 6 3
13 4
2 1 2
8 6 7 1 4 5 2 12 13
7 5 9 6 11 7 4 8
4 12 13 4 9
7 4
5 7 5 6 2 3
2 6 7
5 1 2 3 4 5
6 1 7 2 3 5 4
10 4
2 2 8
3 1 9 8
5 7 5 2 3 9
2 6 9
3 4
3 1 3 2
3 3 1 2
3 2 1 3
1 2
8 4
2 3 7
4 1 3 8 5
1 5
1 7
13 4
9 7 5 3 10 6 11 9 1 8
4 7 4 1 12...

output:

6
8
6
5
3
4
12
3
10
13
10
2
1
8
8
2
4
6
7
5
10
1
12
3
7
11
13
11
12
2
1
2
13
1
5
12
4
6
5
13
5
2
5
9
15
12
4
3
3
2
14
8
2
5
14
13
10
2
4
4
9
6
9
14
3
5
5
6
6
12
4
6
11
1
3
1
8
6
13
5
11
9
2
3
11
9
6
4
5
9
8
4
15
12
14
7
2
7
11
7
4
9
3
5
9
1
2
4
15
3
5
12
10
12
8
11
3
1
5
11
3
7
9
8
11
2
10
9
5
11
3
...

result:

ok 62629 lines

Test #15:

score: 0
Accepted
time: 225ms
memory: 3664kb

input:

47640
7 4
3 1 3 6
6 2 7 1 4 3 6
3 4 2 7
1 4
19 4
15 4 7 2 12 16 5 1 13 8 17 9 11 6 15 14
17 19 14 11 17 9 6 1 3 4 12 10 18 15 2 7 5 16
14 10 6 4 18 5 17 3 11 12 8 19 7 9 14
14 18 6 1 16 4 14 15 19 8 7 17 3 11 12
3 4
2 1 3
1 1
2 2 3
1 1
19 4
14 10 7 12 3 8 19 5 17 13 2 4 9 16 15
10 6 10 9 17 2 19 15 ...

output:

6
18
2
17
10
5
14
19
10
10
9
2
17
10
20
5
7
15
2
15
16
9
9
6
4
1
11
17
17
3
5
1
13
8
18
19
5
6
13
6
7
7
6
1
1
1
12
6
9
15
4
18
5
3
16
9
1
18
12
9
2
5
4
8
19
7
1
3
15
4
1
5
3
16
16
9
2
12
13
17
2
12
16
8
10
12
12
11
16
3
16
1
7
5
12
19
13
18
18
5
2
9
16
6
8
2
10
3
11
11
15
15
6
4
15
1
17
14
12
3
9
15...

result:

ok 47640 lines

Test #16:

score: 0
Accepted
time: 68ms
memory: 3624kb

input:

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

output:

1
45
60
53
66
18
41
7
9
70
69
25
29
44
30
61
17
25
57
15
9
16
47
33
51
11
68
68
9
88
5
4
47
38
55
31
65
6
7
78
41
65
11
58
46
3
29
27
31
72
79
54
40
59
78
32
2
19
53
49
38
75
4
53
78
6
24
38
30
75
52
12
7
64
41
47
61
70
48
47
69
25
72
27
46
34
33
12
44
19
3
76
29
41
40
44
35
56
39
75
5
2
25
16
12
23...

result:

ok 9917 lines

Test #17:

score: 0
Accepted
time: 79ms
memory: 3676kb

input:

1020
485 4
479 113 322 77 59 210 152 46 197 418 217 315 16 446 40 485 305 452 118 129 287 28 10 80 54 469 145 21 228 207 168 220 183 314 68 338 32 271 270 260 364 267 387 324 386 102 419 296 448 143 8 216 121 350 7 240 369 352 239 442 133 112 482 11 186 302 320 274 238 294 196 331 55 463 477 309 269...

output:

479
69
285
548
604
79
412
12
734
665
722
198
769
475
421
177
324
676
668
465
549
143
478
391
462
383
330
538
13
710
612
60
289
692
201
585
196
10
121
176
599
249
708
605
187
95
618
172
174
127
26
111
427
111
141
61
620
199
475
583
751
86
828
224
648
34
520
165
88
652
108
200
362
107
657
50
628
212
4...

result:

ok 1020 lines

Test #18:

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

input:

93
4371 4
1916 1566 1239 1120 681 2377 1684 3943 4170 1815 2618 1360 1627 2557 1104 616 1871 1812 2184 1163 3537 3808 4283 3282 443 2215 2353 3851 3416 2763 2241 983 2821 4011 768 2223 3971 1271 147 1712 1183 4066 2979 3597 2511 1175 7 2078 2349 3200 2808 1646 3000 2634 841 3326 832 3266 2042 3395 4...

output:

3715
1370
4062
7047
2071
4343
8582
2444
6258
4405
2119
5540
3597
2250
4719
1067
2786
3004
4540
2285
4443
1865
9193
1495
4982
3137
5494
5636
4743
8161
6925
8318
713
1019
2679
1586
7667
4164
314
4863
4472
5809
2476
638
3466
4525
5573
6197
8572
943
5458
6844
5826
436
3524
3925
4077
1228
904
1067
1295
2...

result:

ok 93 lines

Test #19:

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

input:

20
14140 4
772 2826 5330 3333 10441 13020 1992 3129 13951 11058 2022 4863 11624 3000 12392 9637 2424 4973 6728 4217 11108 8724 2816 7190 5246 2707 11254 7812 9661 3977 11663 9391 1983 9805 13311 12078 14020 4512 7601 11716 13961 3027 12157 12399 3237 12704 7497 6253 5613 8343 3209 8352 594 9058 850 ...

output:

9423
5225
9545
24087
44289
15071
25948
8097
19267
10441
11867
33352
538
7825
30078
17435
13600
6055
32495
42800

result:

ok 20 lines