QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#78553#4891. 树上的孤独ShmilyTY40 310ms148704kbC++234.0kb2023-02-19 14:25:162023-02-19 14:25:18

详细

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 9ms
memory: 15052kb

input:

20 2000 2000
8 15
8 13
14 8
14 7
12 14
12 1
9 13
9 4
5 9
5 10
2 5
2 19
6 19
6 16
11 7
11 20
18 2
18 17
3 6
1395 1783
1395 1735
1735 457
457 739
739 438
438 101
101 441
441 1879
1879 1238
1238 501
501 1732
1732 1910
1910 2000
2000 834
834 917
917 111
111 780
780 1966
1966 1604
1604 623
623 1748
1748 ...

output:

105
93
2
44
19
54
192
25
69
21
21
200
78
88
137
33
68
68
54
35
24
8
23
78
59
100
27
200
40
74
97
21
87
36
197
76
28
49
11
20
55
60
24
5
109
158
23
21
15
102
36
108
26
78
171
82
32
147
145
9
136
31
109
142
119
68
34
64
18
40
56
48
54
14
35
154
111
130
144
200
21
80
84
37
73
24
28
37
160
51
62
51
95
2...

result:

ok 1481 numbers

Test #2:

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

input:

20 2000 2000
7 9
7 4
20 4
20 15
19 7
19 3
11 9
11 8
5 19
5 1
13 19
13 10
12 5
6 3
17 8
17 14
2 3
2 18
16 5
304 1166
304 1254
1254 1939
1939 430
430 1573
1573 1917
1917 934
934 226
226 1722
1722 453
453 562
562 151
151 1985
1985 1689
1689 1492
1492 108
108 948
948 753
753 92
92 1347
1347 1940
1940 10...

output:

34
197
20
99
87
35
26
19
2
36
87
19
66
199
5
156
19
35
129
62
12
199
96
19
52
4
38
198
19
200
36
60
47
64
44
172
15
48
20
166
147
53
23
46
140
48
56
77
134
39
49
200
67
19
19
40
2
19
158
24
21
79
91
45
12
126
183
20
122
29
21
28
27
65
28
58
141
25
20
172
20
3
179
7
46
141
57
57
43
150
2
86
25
8
72
2...

result:

ok 1495 numbers

Subtask #2:

score: 0
Memory Limit Exceeded

Test #3:

score: 0
Memory Limit Exceeded

input:

20 200000 500000
8 18
8 4
2 4
2 14
13 4
13 16
6 4
6 3
1 4
1 17
15 6
15 19
7 17
7 11
5 14
5 10
20 7
12 15
9 8
165302 77239
165302 198189
165302 180850
165302 192738
165302 173589
165302 194087
165302 191990
165302 167370
165302 101092
165302 92553
165302 163654
165302 122381
165302 152105
165302 1919...

output:


result:


Subtask #3:

score: 30
Accepted

Test #7:

score: 30
Accepted
time: 310ms
memory: 146476kb

input:

20 100000 100000
16 12
16 20
6 12
6 18
2 16
2 8
5 20
5 13
3 6
3 11
19 11
19 17
9 12
9 15
4 15
4 7
10 5
14 15
14 1
85812 94626
85812 91172
91172 93788
93788 96567
96567 75524
75524 23275
23275 98340
98340 81608
81608 91480
91480 75108
75108 56605
56605 93317
93317 41617
41617 77160
77160 727
727 7559...

output:

2568
612
8337
8985
3561
9182
649
301
2478
7307
2682
1175
1401
1268
8228
4407
109
2696
640
4478
3165
9184
21
8980
2092
9950
8009
9944
21
5038
87
2038
1881
19
1292
2183
336
1101
9386
3477
7723
1958
2741
1256
2331
715
21
545
21
448
699
2332
447
18
38
1424
2321
693
2459
21
2320
714
9999
8
196
1366
8933
...

result:

ok 74842 numbers

Test #8:

score: 0
Accepted
time: 273ms
memory: 148544kb

input:

20 100000 100000
6 12
6 15
20 12
20 5
9 15
9 14
2 20
2 19
7 5
7 4
3 20
3 16
10 7
10 8
18 20
18 1
13 4
13 11
17 13
76027 68976
76027 57693
57693 93102
93102 28171
28171 85749
85749 99702
99702 83297
83297 72320
72320 89998
89998 69676
69676 84244
84244 44418
44418 78575
78575 4284
4284 99851
99851 90...

output:

1821
2139
1444
3155
8443
9995
2539
27
64
3274
2129
2
259
2719
152
3900
6031
5006
6290
879
1083
6041
496
6004
670
6
1451
1405
7249
977
9500
402
1104
1444
2795
2267
1171
1971
2886
5045
3
2699
765
3885
241
21
2683
1746
1756
7401
1111
4371
1107
1025
1369
1455
1420
2128
2165
6077
2793
1825
1263
2042
136
...

result:

ok 74861 numbers

Test #9:

score: 0
Accepted
time: 255ms
memory: 145752kb

input:

20 100000 100000
16 17
16 12
15 16
15 8
1 12
1 9
2 15
2 13
7 12
7 5
11 2
11 19
3 8
3 6
4 15
10 17
10 18
14 13
14 20
67546 88879
67546 89198
89198 92647
92647 60049
60049 72475
72475 67403
67403 26140
26140 9738
9738 85753
85753 31691
31691 30604
30604 84416
84416 92592
92592 96710
96710 84006
84006 ...

output:

3320
1811
2176
1515
9571
9829
2737
1223
1728
9815
9933
897
151
272
300
6209
7663
673
1113
918
2190
1241
1106
9988
4
7359
2882
2299
3278
3088
503
3767
1274
2
2160
4738
4304
184
75
2238
3879
192
9987
2744
1320
4089
2428
2759
740
2689
9306
85
3841
1510
3091
3
9327
3677
3221
4692
9315
7211
1780
9997
170...

result:

ok 74827 numbers

Test #10:

score: 0
Accepted
time: 267ms
memory: 148704kb

input:

20 100000 100000
2 3
2 6
17 2
17 10
5 2
5 9
20 10
20 18
7 2
7 16
13 2
13 8
4 10
4 14
11 17
11 15
19 10
19 12
1 11
85514 99510
85514 84831
85514 68620
85514 48208
85514 42479
85514 71645
85514 80596
85514 88493
85514 99514
85514 31378
85514 80504
85514 81861
85514 94839
85514 69330
85514 40591
85514 ...

output:

2
1716
3641
9997
3794
1209
3165
2597
1563
8595
463
4162
893
3028
435
8705
6861
1923
2814
2796
20
2363
1933
1893
762
673
13
7862
2839
2008
2985
2779
9993
2480
3
3712
9951
113
1062
9981
2059
697
3
109
2045
7767
861
149
70
9999
928
21
1017
2082
111
3375
242
1095
3325
880
3574
538
1954
20
376
1434
3507
...

result:

ok 74851 numbers

Test #11:

score: 0
Accepted
time: 263ms
memory: 146236kb

input:

20 100000 100000
12 10
12 5
17 5
14 10
14 8
9 8
9 13
16 12
16 19
6 8
6 3
18 19
18 15
1 12
1 7
20 19
20 4
2 12
11 4
34733 89384
34733 80376
80376 95740
95740 97840
97840 69394
69394 38211
38211 59175
59175 97280
97280 76697
76697 84307
84307 75221
75221 94161
94161 57166
57166 84005
84005 75107
75107...

output:

2486
7650
3313
2
7109
665
5733
1639
3748
5026
3376
3356
4964
9976
4326
982
2015
90
250
1631
3294
625
6789
7678
10000
653
3152
3312
3102
21
7581
2202
230
21
133
9852
3458
21
1652
5963
8692
2
121
3913
1395
3458
7411
3857
1934
355
3
3083
3213
9957
3132
281
8830
1462
6288
2980
1317
1648
897
1353
3303
19...

result:

ok 74832 numbers

Test #12:

score: 0
Accepted
time: 244ms
memory: 143588kb

input:

20 100000 100000
6 8
6 5
9 5
9 11
16 5
16 10
13 8
13 18
20 11
20 4
1 8
1 15
12 5
12 14
7 11
3 13
3 17
19 15
2 10
95202 70596
95202 63084
63084 80990
80990 97264
97264 75236
75236 76413
76413 21787
21787 79077
79077 23111
23111 87359
87359 12982
12982 71974
71974 94809
94809 78084
78084 89131
89131 9...

output:

3795
833
1450
8881
944
1103
4920
6523
2458
3126
642
4493
2278
300
3728
1304
155
474
99
6044
1871
2030
1058
2494
1320
1114
9563
853
1303
3571
377
5761
4259
1225
1700
705
24
1825
3684
2056
2800
9144
3778
1773
61
13
6935
44
9555
5851
2059
1639
3055
1632
2845
9999
9955
1577
610
587
3685
3517
865
66
1521...

result:

ok 74853 numbers

Subtask #4:

score: 0
Runtime Error

Test #13:

score: 0
Runtime Error

input:

1 200000 500000
189127 137023
189127 199761
199761 160701
160701 130639
130639 190908
190908 176819
176819 193363
193363 188021
188021 182446
182446 186028
186028 198828
198828 190792
190792 155378
155378 189428
189428 177276
177276 146159
146159 175923
175923 188073
188073 182206
182206 131072
1310...

output:


result:


Subtask #5:

score: 0
Memory Limit Exceeded

Test #15:

score: 0
Memory Limit Exceeded

input:

20 200000 1000000
13 10
13 5
19 5
19 20
15 10
15 6
12 6
12 3
8 10
8 2
1 20
1 11
14 10
14 16
18 3
18 7
4 3
9 10
9 17
194055 154514
194055 148156
148156 115271
115271 198116
198116 179433
179433 171975
171975 196600
196600 167194
167194 185078
185078 191409
191409 163496
163496 178243
178243 154093
15...

output:


result: