QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#135994#1139. Stationsbashkort#0 50ms4100kbC++201.3kb2023-08-06 17:21:552024-07-04 01:20:01

Judging History

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

  • [2024-07-04 01:20:01]
  • 评测
  • 测评结果:0
  • 用时:50ms
  • 内存:4100kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-06 17:21:55]
  • 提交

stations

#include "stations.h"
#include <bits/stdc++.h>

using namespace std;

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
    vector<vector<int>> adj(n);
    for (int i = 0; i + 1 < n; ++i) {
        adj[u[i]].push_back(v[i]);
        adj[v[i]].push_back(u[i]);
    }
	std::vector<int> labels(n);
    vector<int> siz(n);

    auto dfs1 = [&](auto dfs1, int v, int par) -> void {
        siz[v] = 1;
        for (int &to : adj[v]) {
            if (to != par) {
                dfs1(dfs1, to, v);
                siz[v] += siz[to];
                if (adj[v][0] == par || siz[adj[v][0]] < siz[to]) {
                    swap(to, adj[v][0]);
                }
            }
        }
    };

    dfs1(dfs1, 0, -1);

    int T = 0;

    auto dfs = [&](auto self, int v, int par) -> void {
        for (int to : adj[v]) {
            adj[to].erase(find(adj[to].begin(), adj[to].end(), v));
            if (to != adj[v][0]) {
                T += siz[to];
            }
            self(self, to, v);
        }
        labels[v] = T++;
    };

    dfs(dfs, 0, -1);

    return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
    pair<int, int> best{1e9, -1};
    for (int to : c) {
        best = min(best, pair{abs(to - t), to});
    }
	return best.second;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3684kb

input:

0
10
10 1000
4 5
9 0
2 6
5 2
8 3
1 4
8 1
6 0
3 7
3 1000
0 1
1 2
998 1000
166 178
393 452
389 179
622 429
892 866
872 18
899 227
835 637
587 769
504 386
369 577
65 441
523 17
803 221
878 321
637 892
696 473
16 146
840 322
495 986
353 275
330 585
831 402
719 810
704 830
780 940
53 901
894 911
394 482
...

output:

10
10
3
6
1
4
5
7
0
2
9
3
2
1
0
998
1215
774
1162
1008
489
181
632
628
1129
1111
668
468
1077
210
389
1063
550
727
317
478
134
418
563
310
595
288
279
35
179
677
1204
158
196
296
21
658
543
1104
151
90
742
1003
690
1020
683
34
757
1102
624
519
410
1136
88
425
413
94
1001
1133
732
529
1195
119
1118
7...

input:

1
-1
0

output:


result:

FAIL Unexpected end of file - int32 expected (/opt/uoj/judger/uoj_judger/work/channel_2_answer.txt)

Subtask #2:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 0ms
memory: 3964kb

input:

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

output:

996
4909
2303
4908
1023
2302
3811
4907
447
1022
1726
2301
3235
3810
4487
4906
191
446
766
1021
1470
1725
2045
2300
2979
3234
3554
3809
4231
4486
4779
4905
79
190
334
445
654
765
909
1020
1358
1469
1613
1724
1933
2044
2188
2299
2867
2978
3122
3233
3442
3553
3697
3808
4119
4230
4374
4485
4667
4778
485...

input:

1
-1
0

output:


result:

FAIL Unexpected end of file - int32 expected (/opt/uoj/judger/uoj_judger/work/channel_2_answer.txt)

Subtask #3:

score: 0
Wrong Answer

Test #17:

score: 0
Wrong Answer
time: 36ms
memory: 3800kb

input:

0
10
2 1000000
1 0
997 1000000
830 513
223 672
727 200
763 415
581 440
34 42
267 325
912 693
753 59
401 289
198 641
982 214
41 49
453 107
940 806
905 732
153 482
248 405
102 79
480 837
534 620
564 856
679 178
278 247
899 206
333 672
297 308
407 863
26 752
272 178
204 603
208 10
715 562
785 285
184 5...

output:

2
1
0
997
1129
612
436
285
792
563
338
572
483
827
204
749
1106
233
379
407
1056
1112
818
1045
702
378
681
426
691
1022
193
75
243
464
1101
841
788
523
258
488
467
637
781
157
1042
706
259
628
724
275
56
94
358
707
591
751
565
133
561
129
1046
65
254
148
277
295
251
0
850
1063
512
1009
63
228
861
29...

input:

1
59859
4 0 2
3
13
0 1 1
1
0 1 1
1
968 914 2
967
969
705 603 2
704
706
732 134 2
731
733
1 0 1
0
11 13 2
10
12
877 671 2
876
878
1 0 1
0
1 0 1
0
0 1 1
1
1 0 2
0
2
1095 689 2
1094
1096
628 786 2
627
629
488 496 2
487
489
2 12 2
1
3
0 1 1
1
570 360 2
569
571
68 81 2
67
69
442 416 2
441
443
614 235 2
6...

output:

3
1
1
967
704
731
0
12
876
0
0
1
0
1094
629
489
3
1
569
69
441
613
1018
1013
0
172
361
191
1
1
245
13
456
2
1
1
369
673
206
0
489
187
1007
357
1
2
80
408
22
0
771
2
541
325
19
1040
0
66
2
1
1
4
4
40
604
169
60
2
679
11
731
340
32
2
567
1
134
245
0
716
1
66
480
0
0
705
0
624
0
306
39
9
1
1
731
2
1
0
...

result:

wrong answer Diff at 14-th number: read 1094 but expected 1096

Subtask #4:

score: 0
Wrong Answer

Test #34:

score: 10
Accepted
time: 48ms
memory: 3840kb

input:

0
10
2 1000000000
0 1
2 1000000000
0 1
2 1000000000
1 0
2 1000000000
1 0
2 1000000000
0 1
2 1000000000
1 0
2 1000000000
1 0
2 1000000000
0 1
2 1000000000
0 1
2 1000000000
0 1

output:

2
1
0
2
1
0
2
1
0
2
1
0
2
1
0
2
1
0
2
1
0
2
1
0
2
1
0
2
1
0

input:

1
100000
0 1 1
1
1 0 1
0
1 0 1
0
0 1 1
1
1 0 1
0
0 1 1
1
0 1 1
1
0 1 1
1
0 1 1
1
0 1 1
1
1 0 1
0
0 1 1
1
1 0 1
0
0 1 1
1
1 0 1
0
1 0 1
0
1 0 1
0
0 1 1
1
0 1 1
1
1 0 1
0
0 1 1
1
1 0 1
0
1 0 1
0
0 1 1
1
0 1 1
1
1 0 1
0
1 0 1
0
0 1 1
1
1 0 1
0
1 0 1
0
0 1 1
1
0 1 1
1
0 1 1
1
0 1 1
1
0 1 1
1
1 0 1
0
0 1...

output:

1
0
0
1
0
1
1
1
1
1
0
1
0
1
0
0
0
1
1
0
1
0
0
1
1
0
0
1
0
0
1
1
1
1
1
0
1
0
1
1
1
0
0
1
0
0
0
0
1
1
0
0
1
1
1
0
0
1
0
0
1
0
0
1
1
1
0
1
0
0
0
0
0
0
1
0
1
0
0
0
1
1
1
1
0
1
1
0
1
0
0
1
0
0
0
1
1
1
0
0
0
1
0
1
1
0
1
0
1
0
0
1
1
0
1
1
1
0
0
0
1
1
1
0
0
1
1
0
0
0
1
0
1
0
1
0
0
0
0
1
1
1
1
0
1
1
0
1
1
1
...

result:

ok 

Test #35:

score: 10
Accepted
time: 40ms
memory: 4096kb

input:

0
10
3 1000000000
2 1
2 0
3 1000000000
1 0
2 0
3 1000000000
2 0
0 1
3 1000000000
0 2
1 2
3 1000000000
1 2
1 0
3 1000000000
1 0
2 1
3 1000000000
0 2
1 2
3 1000000000
1 2
1 0
3 1000000000
0 2
1 0
3 1000000000
2 0
1 2

output:

3
2
0
1
3
3
0
2
3
3
2
0
3
2
0
1
3
2
1
0
3
2
1
0
3
2
0
1
3
2
1
0
3
3
2
0
3
2
0
1

input:

1
75069
1 0 2
0
2
3 0 2
0
2
2 0 1
1
2 0 1
1
0 3 1
3
2 0 1
1
0 1 1
1
1 2 2
0
2
0 2 1
3
1 0 2
0
2
1 0 2
0
2
0 2 1
1
1 0 2
0
2
1 0 2
0
2
0 2 1
1
2 0 1
1
1 2 2
0
2
3 0 2
0
2
2 1 1
1
0 1 1
1
1 0 2
0
2
1 0 2
0
2
0 3 1
3
0 1 1
1
2 1 1
1
0 2 1
1
2 1 1
1
0 3 1
3
0 2 1
1
1 2 2
0
2
1 0 2
0
2
3 0 2
0
2
1 2 2
0
...

output:

0
0
1
1
3
1
1
2
3
0
0
1
0
0
1
1
2
0
1
1
0
0
3
1
1
1
1
3
1
2
0
0
2
1
3
1
2
0
1
3
1
1
3
1
2
2
2
1
3
2
1
0
2
1
2
2
1
1
3
1
0
1
1
0
3
0
3
1
0
1
0
1
1
1
0
1
2
3
3
0
3
3
1
3
2
2
0
2
1
2
1
1
0
0
0
1
0
2
0
1
3
3
1
2
3
0
2
0
1
2
0
1
1
2
1
1
2
1
1
1
2
3
0
0
3
1
2
1
0
2
1
2
1
3
0
1
1
0
1
1
3
1
0
1
3
3
3
1
1
1
...

result:

ok 

Test #36:

score: 10
Accepted
time: 30ms
memory: 3804kb

input:

0
10
4 1000000000
3 1
2 0
1 0
4 1000000000
0 3
1 2
3 1
4 1000000000
3 1
0 2
0 1
4 1000000000
2 1
2 3
1 0
4 1000000000
3 1
0 1
2 3
4 1000000000
0 1
3 0
2 3
4 1000000000
2 0
3 0
1 2
4 1000000000
0 2
2 3
1 3
4 1000000000
3 2
2 1
3 0
4 1000000000
2 3
3 0
0 1

output:

4
4
1
3
0
4
3
1
0
2
4
4
1
3
0
4
3
2
1
0
4
3
2
0
1
4
4
3
0
1
4
4
0
1
3
4
3
0
2
1
4
3
0
1
2
4
4
3
0
1

input:

1
66804
4 0 2
1
3
4 0 2
1
3
1 4 2
0
4
3 2 1
2
4 0 2
1
3
1 0 2
0
4
1 0 2
0
2
2 1 2
1
3
3 1 1
2
1 3 2
0
4
4 1 2
1
3
1 4 2
0
4
1 2 2
0
2
3 4 1
4
2 3 2
1
3
3 0 1
4
3 4 1
4
1 0 2
0
4
1 2 2
0
2
0 1 1
1
1 0 2
0
2
3 4 1
4
3 2 1
2
2 0 2
1
3
0 1 1
1
1 3 2
0
4
2 3 2
1
3
0 1 1
1
0 1 1
1
4 3 2
1
3
1 0 2
0
4
0 2 ...

output:

1
1
4
2
1
0
0
1
2
4
1
4
2
4
3
4
4
0
2
1
0
4
2
1
1
4
3
1
1
3
0
1
1
4
2
1
2
1
1
3
4
1
2
1
2
4
1
1
2
1
1
1
3
1
1
1
1
1
0
4
2
4
2
1
1
4
1
3
2
1
1
4
2
1
1
4
1
4
3
1
1
1
2
1
4
3
1
2
1
1
4
1
1
4
2
2
2
1
4
1
0
4
0
1
1
1
3
1
2
1
1
4
1
4
4
4
2
3
4
0
2
1
2
2
1
1
1
1
4
2
0
3
1
2
1
3
1
1
1
4
0
2
2
4
4
3
1
4
3
2
...

result:

ok 

Test #37:

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

input:

0
10
4 1000000000
0 1
1 2
2 3
4 1000000000
0 1
1 3
3 2
4 1000000000
0 2
2 1
1 3
4 1000000000
0 2
2 3
3 1
4 1000000000
0 3
3 1
1 2
4 1000000000
0 3
3 2
2 1
4 1000000000
1 0
0 2
2 3
4 1000000000
1 0
0 3
3 2
4 1000000000
1 2
2 0
0 3
4 1000000000
1 3
3 0
0 2

output:

4
3
2
1
0
4
3
2
0
1
4
3
1
2
0
4
3
0
2
1
4
3
1
0
2
4
3
0
1
2
4
4
3
1
0
4
4
3
0
1
4
4
0
1
3
4
4
0
3
1

input:

1
120
1 2 2
0
2
0 1 1
1
0 1 1
1
3 0 1
2
3 0 1
4
2 1 2
1
3
3 0 1
4
3 1 1
2
3 2 1
2
0 2 1
1
1 3 2
0
2
0 1 1
1
4 1 2
1
3
1 0 2
0
2
2 3 2
1
3
0 3 1
1
1 3 2
0
2
3 4 1
4
0 2 1
1
3 1 1
4
0 2 1
1
4 3 2
1
3
4 1 2
1
3
0 4 1
1
2 3 2
1
3
4 1 2
1
3
0 3 1
1
1 4 2
0
4
0 4 1
1
0 1 1
1
3 0 1
2
2 0 2
1
3
2 1 2
1
3
3 ...

output:

2
1
1
2
4
1
4
2
2
1
2
1
1
0
3
1
2
4
1
4
1
3
1
1
3
1
1
4
1
1
2
1
1
2
2
3
2
2
2
2
1
0
0
1
1
0
1
0
1
1
1
2
4
4
1
4
2
2
1
1
1
2
0
4
0
2
4
2
1
4
3
2
1
4
1
4
1
2
4
1
1
2
2
2
3
4
1
1
1
3
2
0
2
4
1
4
1
2
1
2
1
3
3
1
1
2
1
1
4
1
1
0
3
1
1
1
2
4
0
4

result:

ok 

Test #38:

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

input:

0
10
6 1000000000
0 1
1 2
2 3
3 4
4 5
6 1000000000
0 1
1 2
2 3
3 5
5 4
6 1000000000
0 1
1 2
2 4
4 3
3 5
6 1000000000
0 1
1 2
2 4
4 5
5 3
6 1000000000
0 1
1 2
2 5
5 3
3 4
6 1000000000
0 1
1 2
2 5
5 4
4 3
6 1000000000
0 1
1 3
3 2
2 4
4 5
6 1000000000
0 1
1 3
3 2
2 5
5 4
6 1000000000
0 1
1 3
3 4
4 2
2 ...

output:

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

input:

1
300
5 0 1
4
4 0 2
3
5
3 4 2
2
4
1 0 2
0
2
2 5 2
1
3
5 4 1
4
4 5 2
3
5
5 4 1
4
5 4 1
4
4 2 2
3
5
2 1 2
1
3
5 1 1
4
0 3 1
1
2 0 2
1
3
5 4 1
4
3 0 2
2
4
5 0 1
4
3 1 2
2
4
5 1 1
4
0 5 1
1
1 4 2
0
2
4 3 2
3
5
3 1 2
2
4
2 4 2
1
3
2 1 2
1
3
4 0 2
3
5
1 3 2
0
2
5 3 1
4
5 1 1
4
4 2 2
3
5
3 4 2
2
4
3 2 2
2
...

output:

4
3
4
0
3
4
5
4
4
3
1
4
1
1
4
2
4
2
4
1
2
3
2
3
1
3
2
4
4
3
4
2
5
1
5
1
5
3
1
3
3
3
4
3
0
4
1
2
2
1
4
4
2
1
2
2
4
3
4
2
1
1
1
4
1
4
1
1
1
3
1
1
0
2
2
4
2
4
2
0
3
3
3
4
2
4
4
1
2
2
0
1
1
5
1
2
1
2
1
4
1
3
3
0
3
5
4
2
2
2
2
1
3
2
1
2
4
1
1
1
3
4
2
4
3
3
1
1
1
3
3
3
2
4
1
2
1
4
3
2
1
3
3
1
3
5
2
2
1
1
...

result:

ok 

Test #39:

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

input:

0
3
3 1000000000
0 1
1 2
3 1000000000
0 2
2 1
3 1000000000
1 0
0 2

output:

3
2
1
0
3
2
0
1
3
3
0
2

input:

1
18
1 0 2
0
2
1 2 2
0
2
1 2 2
0
2
0 2 1
1
2 3 1
3
0 3 1
3
0 1 1
1
2 0 1
3
1 0 2
0
2
3 0 2
0
2
0 2 1
3
2 0 1
1
2 0 1
1
2 1 1
1
0 1 1
1
0 2 1
1
2 1 1
1
3 2 2
0
2

output:

0
2
2
1
3
3
1
3
0
0
3
1
1
1
1
1
1
2

result:

ok 

Test #40:

score: 10
Accepted
time: 36ms
memory: 4096kb

input:

0
10
4 1000000000
1 3
1 2
0 1
4 1000000000
2 3
3 0
1 3
4 1000000000
2 0
1 3
0 1
4 1000000000
1 2
3 1
1 0
4 1000000000
3 1
0 2
3 2
4 1000000000
2 0
2 1
2 3
4 1000000000
1 2
1 3
2 0
4 1000000000
0 2
2 3
2 1
4 1000000000
2 1
2 0
3 0
4 1000000000
3 0
3 2
1 0

output:

4
4
3
2
0
4
4
2
0
3
4
4
1
3
0
4
4
3
0
2
4
3
0
2
1
4
4
0
3
2
4
3
1
2
0
4
4
2
3
0
4
4
0
1
3
4
4
3
0
1

input:

1
66674
0 1 1
1
0 2 1
3
3 0 3
0
2
4
0 2 1
3
2 0 2
1
3
3 0 3
0
2
4
4 3 2
1
3
3 4 3
0
2
4
3 0 3
0
2
4
2 1 2
1
3
0 1 1
1
1 3 2
0
4
4 2 1
3
2 4 1
3
3 0 1
4
3 0 1
4
4 3 1
3
1 3 2
0
4
0 4 1
3
2 0 1
3
1 2 2
0
2
2 0 1
3
1 3 2
0
4
1 2 2
0
2
3 0 1
4
1 0 2
0
2
2 3 1
3
0 2 1
3
2 4 1
3
1 0 2
0
2
4 0 2
1
3
4 1 2
...

output:

1
3
0
3
1
0
3
4
0
1
1
4
3
3
4
4
3
4
3
3
2
3
4
2
4
0
3
3
3
0
1
1
3
1
4
3
4
2
3
2
3
3
1
1
2
1
3
3
3
1
4
4
3
3
4
3
4
3
0
3
1
2
3
2
3
3
4
0
4
1
2
1
3
4
1
1
3
2
4
2
3
2
4
3
4
4
1
4
3
1
4
3
3
1
3
3
1
4
1
3
3
1
1
3
1
3
3
1
1
1
1
2
1
3
2
3
3
4
1
4
3
3
0
2
3
1
3
2
0
1
2
3
4
4
0
3
3
0
2
1
3
3
2
1
1
3
3
2
4
1
...

result:

ok 

Test #41:

score: 10
Accepted
time: 50ms
memory: 3836kb

input:

0
10
2 1000000000
1 0
2 1000000000
0 1
2 1000000000
1 0
2 1000000000
1 0
2 1000000000
1 0
2 1000000000
0 1
2 1000000000
1 0
2 1000000000
1 0
2 1000000000
1 0
2 1000000000
0 1

output:

2
1
0
2
1
0
2
1
0
2
1
0
2
1
0
2
1
0
2
1
0
2
1
0
2
1
0
2
1
0

input:

1
100000
0 1 1
1
0 1 1
1
1 0 1
0
0 1 1
1
1 0 1
0
1 0 1
0
1 0 1
0
0 1 1
1
1 0 1
0
0 1 1
1
0 1 1
1
1 0 1
0
1 0 1
0
0 1 1
1
0 1 1
1
1 0 1
0
1 0 1
0
1 0 1
0
1 0 1
0
0 1 1
1
0 1 1
1
0 1 1
1
0 1 1
1
1 0 1
0
0 1 1
1
1 0 1
0
1 0 1
0
0 1 1
1
0 1 1
1
1 0 1
0
1 0 1
0
1 0 1
0
1 0 1
0
1 0 1
0
0 1 1
1
0 1 1
1
0 1...

output:

1
1
0
1
0
0
0
1
0
1
1
0
0
1
1
0
0
0
0
1
1
1
1
0
1
0
0
1
1
0
0
0
0
0
1
1
1
1
1
1
0
1
0
0
1
0
1
0
1
0
0
0
1
1
1
1
0
1
1
1
0
1
0
1
1
0
0
1
1
1
0
0
1
0
0
1
1
1
1
0
1
0
0
0
1
0
0
1
1
1
0
0
1
1
1
1
1
0
0
1
0
0
0
1
0
0
1
1
0
0
0
1
0
0
0
1
1
0
0
1
0
1
1
1
1
0
0
1
0
0
0
1
1
0
0
0
1
0
1
0
1
1
1
1
1
1
1
1
1
1
...

result:

ok 

Test #42:

score: 10
Accepted
time: 40ms
memory: 3772kb

input:

0
10
3 1000000000
0 1
0 2
3 1000000000
0 1
0 2
3 1000000000
1 0
2 0
3 1000000000
1 0
0 2
3 1000000000
1 0
2 0
3 1000000000
1 0
2 0
3 1000000000
1 0
0 2
3 1000000000
1 0
2 0
3 1000000000
1 0
0 2
3 1000000000
0 1
0 2

output:

3
3
0
2
3
3
0
2
3
3
0
2
3
3
0
2
3
3
0
2
3
3
0
2
3
3
0
2
3
3
0
2
3
3
0
2
3
3
0
2

input:

1
75040
2 0 1
3
2 3 1
3
0 3 1
3
3 2 2
0
2
0 2 1
3
0 3 1
3
3 2 2
0
2
2 3 1
3
0 2 1
3
3 2 2
0
2
0 2 1
3
3 0 2
0
2
3 2 2
0
2
3 2 2
0
2
3 0 2
0
2
0 2 1
3
2 0 1
3
3 2 2
0
2
2 3 1
3
2 3 1
3
0 2 1
3
3 2 2
0
2
3 2 2
0
2
0 2 1
3
3 0 2
0
2
0 3 1
3
2 0 1
3
2 3 1
3
2 3 1
3
2 0 1
3
0 2 1
3
3 2 2
0
2
2 3 1
3
2 3 ...

output:

3
3
3
2
3
3
2
3
3
2
3
0
2
2
0
3
3
2
3
3
3
2
2
3
0
3
3
3
3
3
3
2
3
3
3
3
2
0
3
0
3
3
0
3
3
0
2
3
3
0
0
3
3
0
3
0
0
2
3
3
3
0
0
0
0
3
3
2
3
3
2
3
0
2
2
3
3
3
3
3
3
3
2
2
2
3
3
3
3
0
3
3
2
0
3
3
3
3
2
3
3
3
3
3
3
3
2
3
3
3
3
3
0
3
3
3
3
3
3
3
2
3
3
3
3
3
0
2
0
3
0
0
3
2
0
3
0
3
3
3
3
0
0
3
2
3
0
3
2
3
...

result:

ok 

Test #43:

score: 10
Accepted
time: 36ms
memory: 3808kb

input:

0
10
4 1000000000
0 1
2 0
1 3
4 1000000000
0 1
0 2
3 1
4 1000000000
0 1
0 2
3 1
4 1000000000
0 1
0 2
1 3
4 1000000000
0 1
0 2
3 1
4 1000000000
0 1
0 2
1 3
4 1000000000
0 1
0 2
3 1
4 1000000000
0 1
0 2
3 1
4 1000000000
1 0
0 2
1 3
4 1000000000
0 1
2 0
3 1

output:

4
4
1
3
0
4
4
1
3
0
4
4
1
3
0
4
4
1
3
0
4
4
1
3
0
4
4
1
3
0
4
4
1
3
0
4
4
1
3
0
4
4
1
3
0
4
4
1
3
0

input:

1
66554
1 0 2
0
4
4 0 2
1
3
3 1 1
4
0 1 1
1
3 0 1
4
4 3 2
1
3
0 1 1
1
1 0 2
0
4
3 4 1
4
3 1 1
4
0 1 1
1
0 1 1
1
1 4 2
0
4
1 4 2
0
4
1 3 2
0
4
3 1 1
4
3 1 1
4
1 4 2
0
4
3 0 1
4
4 3 2
1
3
4 0 2
1
3
1 3 2
0
4
1 4 2
0
4
1 0 2
0
4
3 1 1
4
4 0 2
1
3
3 1 1
4
4 0 2
1
3
4 3 2
1
3
4 0 2
1
3
4 0 2
1
3
3 1 1
4
...

output:

0
1
4
1
4
3
1
0
4
4
1
1
4
4
4
4
4
4
4
3
1
4
4
0
4
1
4
1
3
1
1
4
4
4
1
0
1
0
4
4
4
1
4
1
4
1
1
1
4
3
1
4
3
1
4
3
0
1
1
4
4
1
4
4
1
4
4
3
1
1
3
1
1
1
1
3
4
0
4
4
1
1
1
1
0
4
1
1
4
1
1
1
4
4
3
4
4
4
1
1
3
4
1
1
1
4
1
1
1
4
1
1
1
1
1
0
4
4
4
1
3
4
4
1
0
4
4
1
1
4
0
1
1
1
1
4
1
0
1
1
1
4
4
3
4
1
4
4
1
4
...

result:

ok 

Test #44:

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

input:

0
10
7 1000000000
5 3
6 3
0 3
4 3
1 3
2 3
7 1000000000
3 0
4 0
5 0
1 0
2 0
6 0
7 1000000000
4 0
2 0
3 0
6 0
1 0
5 4
7 1000000000
4 1
0 1
5 1
3 1
2 1
6 4
7 1000000000
3 1
2 1
5 1
4 1
6 1
0 3
7 1000000000
6 3
1 3
0 3
2 3
4 6
5 6
7 1000000000
5 0
4 0
3 0
2 0
6 5
1 5
7 1000000000
0 1
6 1
5 1
3 1
4 0
2 0...

output:

7
10
6
8
9
4
0
2
7
11
6
8
0
2
4
10
7
10
9
3
5
1
0
7
7
9
8
7
5
1
3
0
7
9
7
0
8
4
2
6
7
9
5
7
8
0
2
3
7
10
2
9
7
5
3
0
7
10
5
9
4
7
2
0
7
8
1
3
7
0
5
6
7
10
9
1
4
5
7
0

input:

1
420
3 7 3
0
2
8
7 1 1
8
1 5 2
0
10
5 9 1
8
5 9 1
10
0 9 1
3
2 4 1
5
2 8 1
3
4 6 1
9
7 6 5
0
2
4
6
8
3 9 1
8
9 8 1
8
8 9 5
1
3
5
7
9
0 7 1
1
0 2 1
5
0 8 1
9
6 2 1
9
4 8 1
7
2 11 1
11
4 7 1
5
7 5 1
10
7 3 2
6
8
9 0 1
10
10 0 5
1
3
5
7
9
0 6 1
11
2 7 1
7
4 2 1
9
9 0 1
8
1 3 2
0
10
7 9 5
0
2
4
6
8
9 7...

output:

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

result:

wrong answer Diff at 3-th number: read 0 but expected 10

Subtask #5:

score: 0
Wrong Answer

Test #54:

score: 0
Wrong Answer
time: 36ms
memory: 3816kb

input:

0
10
3 1000000000
1 0
2 1
998 1000000000
928 443
90 795
55 379
957 417
759 300
960 136
309 858
833 370
228 827
876 955
619 365
15 108
243 388
54 925
141 894
272 634
0 989
600 346
380 277
350 113
326 613
975 946
660 98
34 538
220 864
9 585
185 860
458 424
509 14
22 275
109 872
153 233
76 834
972 736
...

output:

3
2
1
0
998
1200
662
681
283
77
1060
367
64
781
470
1018
312
761
282
366
117
1026
1072
76
1148
612
1111
249
437
423
1138
1015
49
633
363
739
51
377
181
460
740
558
278
201
715
1188
498
36
137
455
442
58
214
742
1109
720
1124
570
1146
790
702
224
463
1151
1191
621
342
544
304
648
1126
371
188
438
187...

input:

1
59797
1 0 2
0
2
227 133 2
226
228
0 1 1
1
15 48 2
14
16
1271 78 2
1270
1272
2 3 2
1
3
2 0 2
1
3
676 380 2
675
677
54 456 2
53
55
421 271 2
420
422
1 0 1
0
256 248 2
255
257
362 365 2
361
363
747 553 2
746
748
1 2 2
0
2
667 65 2
666
668
484 82 2
483
485
74 60 2
73
75
1 0 2
0
2
824 354 2
823
825
57 ...

output:

0
226
1
16
1270
3
1
675
55
420
0
255
363
746
2
666
483
73
0
823
58
1
2
437
1009
94
166
1048
345
0
2
785
766
1
742
68
1104
1009
31
1
1
0
257
721
1
112
304
133
455
1
0
1034
220
2
4
244
314
0
1018
2
0
524
5
6
399
1375
2
107
1253
108
100
675
801
1350
824
149
0
77
18
608
1
1068
1
2
2
626
454
590
0
2
1109...

result:

wrong answer Diff at 5-th number: read 1270 but expected 1272