QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#234918#2028. Sum of DistancesGMBox100 ✓63ms23852kbC++202.2kb2023-11-02 02:36:552023-11-02 02:36:55

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 5
Accepted
time: 4ms
memory: 13640kb

input:

2

2 1
1 2

4 4
1 2
2 3
3 4
4 1

output:

4

result:

ok single line: '4'

Test #2:

score: 5
Accepted
time: 0ms
memory: 13568kb

input:

3

4 4
1 2
2 3
3 1
3 4

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

7 7
1 2
2 3
3 4
4 5
5 6
6 7
7 1

output:

706

result:

ok single line: '706'

Test #3:

score: 5
Accepted
time: 0ms
memory: 13600kb

input:

4

6 9
1 2
6 1
6 5
3 2
4 2
6 3
6 4
2 2
5 5

4 4
1 3
2 1
4 1
4 3

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

2 2
1 2
2 2

output:

584

result:

ok single line: '584'

Test #4:

score: 5
Accepted
time: 3ms
memory: 13568kb

input:

3

6 7
5 1
2 5
5 6
5 4
5 3
5 5
6 2

7 8
7 1
7 2
7 6
7 3
7 5
4 7
7 7
6 4

7 9
1 4
5 1
3 1
6 5
2 3
4 7
5 7
3 4
7 7

output:

624

result:

ok single line: '624'

Test #5:

score: 5
Accepted
time: 0ms
memory: 13624kb

input:

7

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

output:

460766347

result:

ok single line: '460766347'

Test #6:

score: 5
Accepted
time: 0ms
memory: 13620kb

input:

7

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

output:

992835123

result:

ok single line: '992835123'

Test #7:

score: 5
Accepted
time: 4ms
memory: 13556kb

input:

8

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

31 43
21 1
21 2
22 21
2 25
15 2...

output:

210628586

result:

ok single line: '210628586'

Test #8:

score: 5
Accepted
time: 4ms
memory: 13724kb

input:

9

26 34
1 5
20 1
5 23
6 23
26 23
6 18
9 18
18 4
21 18
18 19
7 19
24 7
24 10
24 12
10 15
10 14
13 14
22 13
22 25
25 16
16 11
3 11
2 3
17 3
17 8
26 18
23 20
12 15
8 2
12 14
21 7
15 13
4 7
9 7

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

output:

8496383

result:

ok single line: '8496383'

Test #9:

score: 5
Accepted
time: 0ms
memory: 13612kb

input:

3

100 364
1 52
82 52
59 82
5 59
5 39
39 63
63 56
19 56
19 75
3 75
3 7
99 7
83 99
83 49
46 49
46 81
60 81
88 60
88 54
54 16
16 33
33 22
93 22
69 93
69 65
92 65
79 92
79 30
36 30
10 36
76 10
76 96
72 96
97 5
24 97
24 66
100 66
100 31
31 2
2 95
51 95
9 51
9 25
55 54
42 55
67 42
43 67
80 43
58 80
85 67...

output:

53759656

result:

ok single line: '53759656'

Test #10:

score: 5
Accepted
time: 0ms
memory: 13616kb

input:

2

150 610
102 1
102 119
119 83
83 108
108 87
117 87
105 117
105 19
110 19
84 110
30 84
3 30
3 122
39 122
39 7
36 7
36 134
134 143
94 143
94 73
73 86
86 12
46 12
20 46
20 115
115 64
6 64
90 6
90 62
78 62
78 59
2 59
2 109
109 23
89 23
89 32
32 66
125 66
22 125
22 80
80 120
120 144
14 144
106 14
106 6...

output:

684017

result:

ok single line: '684017'

Test #11:

score: 5
Accepted
time: 28ms
memory: 22812kb

input:

4

23117 31016
15339 1
18183 15339
18386 18183
18386 22392
22392 21512
4610 21512
4610 20085
20085 8524
8524 22462
8592 22462
8592 51
51 11056
10416 11056
14763 10416
13116 14763
13116 1867
1012 1867
1012 5381
16719 5381
18091 16719
18091 11602
11602 10407
10407 3804
3804 11865
22560 11865
22560 651...

output:

366418740

result:

ok single line: '366418740'

Test #12:

score: 5
Accepted
time: 33ms
memory: 23136kb

input:

4

29660 37074
7732 1
7732 26844
26844 13539
19772 13539
19772 19943
24912 19943
24912 22782
11466 22782
21958 11466
80 21958
80 24277
4552 24277
16470 4552
7673 16470
3724 7673
28403 3724
28403 19775
9061 19775
9061 7280
7280 9357
8784 9357
8784 25331
22511 25331
27677 22511
24915 27677
24915 7038
...

output:

50590863

result:

ok single line: '50590863'

Test #13:

score: 5
Accepted
time: 19ms
memory: 19284kb

input:

4

17768 27936
5883 1
15274 5883
15274 6557
8242 6557
8242 3908
3908 8264
9939 8264
2586 9939
10204 2586
10204 4334
17706 4334
10822 17706
5497 10822
5497 7829
3508 7829
3508 11893
11893 10923
13724 10923
13724 5777
8226 5777
1824 8226
1824 2655
7343 2655
7343 12531
10713 12531
10713 16978
16978 400...

output:

96060131

result:

ok single line: '96060131'

Test #14:

score: 5
Accepted
time: 43ms
memory: 22524kb

input:

5

5661 10842
335 1
5413 335
5413 2910
2910 2724
494 2724
5661 494
5661 2225
2225 2466
154 2466
2253 154
2253 324
3989 324
3989 1874
1874 1838
3613 1838
1007 3613
5047 1007
5047 1691
1691 5040
5040 2114
4583 2114
828 4583
828 2780
2780 3060
3060 307
3367 307
3367 3876
3876 3734
344 3734
344 5000
263...

output:

796882453

result:

ok single line: '796882453'

Test #15:

score: 5
Accepted
time: 28ms
memory: 21044kb

input:

4

24058 28068
10501 1
10501 10377
23386 10377
23386 9275
9275 23999
215 23999
5802 215
5802 19904
19904 5035
5035 18165
18165 23834
23834 1765
1765 19536
19536 4835
4835 2870
11994 2870
995 11994
995 658
658 23342
12849 23342
12849 429
13542 429
5179 13542
796 5179
796 15357
15090 15357
15090 3102
...

output:

442017446

result:

ok single line: '442017446'

Test #16:

score: 5
Accepted
time: 36ms
memory: 21792kb

input:

3

28636 38180
1 21059
21059 27618
27618 3489
11385 3489
707 11385
707 11534
3986 11534
12738 3986
34 12738
34 6006
18609 6006
9400 18609
21255 9400
6028 21255
6062 6028
22964 6062
14495 22964
7388 14495
7388 26432
15081 26432
15081 2823
2823 20061
20061 2269
22556 2269
22556 13227
13227 13831
13831...

output:

449885053

result:

ok single line: '449885053'

Test #17:

score: 5
Accepted
time: 32ms
memory: 22320kb

input:

5

11512 13745
1 9946
11383 9946
4023 11383
4023 8570
7785 8570
7636 7785
4221 7636
3546 4221
3546 6412
5355 6412
5355 231
231 11356
2350 11356
2350 2888
909 2888
10787 909
697 10787
697 7080
6022 7080
2939 6022
2939 6841
6841 8698
8698 4348
618 4348
8682 618
8682 7425
7425 10885
4142 10885
4142 712...

output:

675724391

result:

ok single line: '675724391'

Test #18:

score: 5
Accepted
time: 18ms
memory: 19816kb

input:

4

22433 22432
16109 1
16109 10213
10213 16688
16688 4008
9540 4008
19917 9540
8764 19917
7126 8764
7126 10262
18670 10262
183 18670
183 11341
11341 10341
15571 10341
22307 15571
22307 18130
20176 18130
20176 6400
20999 6400
20999 10607
11444 10607
11444 22422
22422 8224
17322 8224
17322 14725
14725...

output:

761227822

result:

ok single line: '761227822'

Test #19:

score: 5
Accepted
time: 63ms
memory: 22844kb

input:

669

168 222
1 157
157 16
143 16
39 143
116 39
116 25
27 25
119 27
119 60
60 67
67 66
66 164
52 164
52 3
3 83
83 56
20 56
20 63
63 103
80 103
89 80
131 89
131 104
104 45
122 45
122 44
44 59
156 59
156 76
163 76
163 144
101 144
134 101
134 33
33 50
50 37
37 95
95 73
26 73
109 26
34 109
34 106
106 86
...

output:

729294506

result:

ok single line: '729294506'

Test #20:

score: 5
Accepted
time: 46ms
memory: 23852kb

input:

2

10000 13561
3968 1
5400 3968
927 5400
927 1762
6452 1762
6452 9297
8328 9297
8328 6973
6973 7748
7748 3887
3887 476
867 476
867 9611
3367 9611
5690 3367
5690 142
142 4438
4438 6723
7794 6723
7794 6996
6996 184
184 419
7801 419
4780 7801
2353 4780
2250 2353
2250 7953
7953 1536
1536 4947
9471 4947
...

output:

745939593

result:

ok single line: '745939593'