QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#499857#1139. StationsDan4Life0 50ms4092kbC++231.1kb2024-07-31 19:42:122024-07-31 19:42:12

Judging History

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

  • [2024-07-31 19:42:12]
  • 评测
  • 测评结果:0
  • 用时:50ms
  • 内存:4092kb
  • [2024-07-31 19:42:12]
  • 提交

stations

#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
using ll = long long;
using vi = vector<int>;
const int mxN = 1010;
int dfs_timer = 0;
vi labels, adj[mxN];

void dfs(int s, int p, int dep){
	if(!dep) labels[s] = dfs_timer++;
	dfs_timer++;
	for(auto u : adj[s])
		if(u!=p) dfs(u,s,dep^1);
	if(dep) labels[s] = dfs_timer++;
}

vi label(int n, int k, vi u, vi v) {
	labels.clear(); labels.resize(n,0); dfs_timer=0;
	for(int i = 0; i < n; i++) adj[i].clear();
	for(int i = 0; i < sz(u); i++){
		int a = u[i], b = v[i];
		adj[a].pb(b), adj[b].pb(a);
	}
	dfs(0,-1, 0); return labels;
}

int find_next_station(int s, int t, vi c) {
	if(sz(c)==1) return c[0];
	for(auto u : c) if(u==t) return u;
	if(s < c[0]){
		if(!s or (s<=t and t<=end(c)[-2]+1)){
			for(int i = 1; i < sz(c)-!!s; i++)
				if(c[i-1]+1<=t and t<=c[i]) return c[i];
			return c[0];
		}
		return c.back();
	}
	if(c[1]-1<=t and t<=s){
		for(int i = 1; i < sz(c)-1; i++)
			if(c[i]<=t and t<=c[i+1]-1) return c[i];
		return c.back();
	}
	return c[0];
}

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: 3688kb

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
0
17
5
16
8
18
19
14
11
3
3
0
5
3
998
0
1993
411
334
871
1333
1922
1920
129
156
1940
1840
207
1711
1021
228
1881
514
1129
1845
1673
1815
760
1761
712
1750
1186
1552
1336
589
432
1685
1704
1754
1573
1935
790
382
1378
1651
1977
318
1951
340
580
1623
469
381
1918
826
1811
398
1650
967
985
1653
321
1...

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: 3724kb

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
0
1023
1991
3
513
1025
1535
258
512
768
1022
1280
1534
1790
1990
6
132
260
386
516
642
770
896
1028
1154
1282
1408
1538
1664
1792
1918
69
131
195
257
323
385
449
511
579
641
705
767
833
895
959
1021
1091
1153
1217
1279
1345
1407
1471
1533
1601
1663
1727
1789
1855
1917
1959
1989
9
39
71
101
135
1...

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: 16
Accepted
time: 38ms
memory: 3796kb

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
0
3
997
0
1602
1514
867
1692
450
1465
1582
570
54
1398
171
1982
945
726
684
1957
1985
1705
1852
1647
1485
273
1509
258
1940
1005
1182
930
1528
1768
33
1690
510
1425
1540
594
339
123
1059
1950
1649
906
1610
1658
882
1324
1343
1475
234
408
168
447
1095
453
1101
1952
1197
1423
1370
879
852
918
1296
1...

input:

1
59859
11 9 2
0
3
3 0 1
0
3 0 1
0
1984 1957 2
45
48
487 640 2
1898
1899
400 1297 2
1865
1866
0 3 1
3
13 0 2
18
19
183 492 2
1938
1939
0 3 1
3
0 3 1
3
3 0 1
0
5 3 2
0
3
1777 261 2
1976
1977
1814 1893 2
555
558
1744 1748 2
765
768
10 19 2
3
6
3 5 1
5
1581 1476 2
438
441
54 198 2
191
192
835 874 2
172...

output:

3
0
0
48
1898
1865
3
19
1938
3
3
0
3
1977
555
765
3
5
441
192
1720
625
1938
1897
3
1418
789
1044
5
3
963
0
814
7
0
3
1684
489
1189
3
561
1050
1927
963
6
7
1586
1500
1557
3
388
7
733
1057
167
166
3
57
0
0
5
11
11
96
1634
1245
66
7
480
13
402
1502
108
7
1783
3
1613
1131
3
1654
5
1399
1740
3
3
237
3
18...

result:

ok 

Test #18:

score: 16
Accepted
time: 36ms
memory: 3744kb

input:

0
10
999 1000000
719 816
256 855
722 661
705 575
610 707
632 426
296 99
891 512
445 475
76 601
63 756
576 934
73 186
606 363
702 69
48 768
568 128
904 82
223 805
146 382
922 467
347 433
959 614
709 998
296 4
544 64
165 989
856 470
370 230
239 810
911 976
728 952
162 752
682 305
511 782
113 37
576 41...

output:

999
0
1904
1287
1240
819
339
1431
1503
1227
1609
1394
1630
1828
1428
1720
309
1443
1477
1603
1241
915
384
1104
1217
789
912
813
1257
561
774
1908
1581
1753
1116
765
1371
1922
1459
1348
1270
1188
1347
81
249
1423
1514
1366
1920
1495
1834
264
1226
24
1161
1068
1318
1876
1768
1484
747
1578
1486
1206
19...

input:

1
50048
1787 1581 2
222
225
513 1244 2
1316
1317
1957 1935 2
1588
1591
1567 1777 2
882
885
714 1933 2
1363
1364
414 1310 2
1463
1464
1963 1770 2
1914
1917
1429 1534 2
1296
1299
825 1828 2
1212
1213
12 645 2
1919
1920
795 1509 2
1336
1337
448 216 2
1989
1990
1796 1181 2
1775
1778
1499 1692 2
1272
127...

output:

225
1316
1591
882
1364
1463
1914
1296
1213
1919
1337
1990
1775
1272
753
955
1251
927
1961
1884
924
1825
1955
580
1972
1192
354
177
1471
1160
1212
332
1053
399
1880
1748
1638
531
282
1072
186
670
1206
1505
973
1490
237
991
282
744
972
1143
1388
1874
1557
1714
943
299
667
111
351
1699
1597
1380
1838
1...

result:

ok 

Test #19:

score: 16
Accepted
time: 48ms
memory: 3808kb

input:

0
10
2 1000000
0 1
2 1000000
0 1
2 1000000
1 0
2 1000000
0 1
2 1000000
1 0
2 1000000
0 1
2 1000000
1 0
2 1000000
1 0
2 1000000
1 0
2 1000000
1 0

output:

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

input:

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

output:

3
3
0
3
0
3
3
3
0
3
0
3
0
0
0
0
3
0
0
3
3
3
3
0
3
3
3
0
3
3
0
0
3
3
3
3
0
0
3
3
3
0
3
3
0
3
0
0
0
3
0
3
0
0
0
3
0
0
3
0
0
0
0
0
0
0
3
0
3
3
0
3
3
0
3
0
3
3
3
0
3
0
0
3
0
0
0
3
3
0
3
3
0
0
3
3
0
0
3
3
3
3
3
3
3
0
0
3
0
0
0
0
3
0
3
3
0
0
0
3
3
0
0
3
3
3
0
0
3
0
0
3
0
0
0
0
0
3
0
3
0
0
3
0
3
3
3
3
3
0
...

result:

ok 

Test #20:

score: 16
Accepted
time: 40ms
memory: 4040kb

input:

0
10
3 1000000
1 0
0 2
3 1000000
2 0
0 1
3 1000000
2 1
2 0
3 1000000
2 0
2 1
3 1000000
0 1
1 2
3 1000000
1 0
1 2
3 1000000
2 0
2 1
3 1000000
0 1
2 1
3 1000000
2 1
0 1
3 1000000
0 2
2 1

output:

3
0
3
5
3
0
5
3
3
0
3
5
3
0
3
5
3
0
5
3
3
0
5
3
3
0
3
5
3
0
5
3
3
0
5
3
3
0
3
5

input:

1
74899
0 3 1
5
3 0 1
5
3 5 1
5
3 0 1
0
5 3 1
0
0 3 2
3
5
5 0 2
0
3
0 5 1
5
0 3 1
5
5 3 2
0
3
0 5 2
3
5
0 5 1
5
0 5 1
5
3 0 1
5
3 5 1
5
0 3 1
5
0 3 1
5
0 3 1
5
5 0 1
0
5 0 2
0
3
5 3 2
0
3
3 0 1
5
0 3 1
5
0 5 1
5
3 0 1
5
0 5 2
3
5
5 3 2
0
3
0 3 1
5
5 3 1
0
5 3 1
0
0 5 1
5
3 5 1
5
0 3 1
5
5 0 2
0
3
0 ...

output:

5
5
5
0
0
3
0
5
5
3
5
5
5
5
5
5
5
5
0
0
3
5
5
5
5
5
3
5
0
0
5
5
5
0
5
5
5
5
5
0
3
5
0
5
5
5
5
5
0
0
5
5
0
5
3
3
0
3
5
3
0
5
3
5
3
5
0
3
0
5
5
5
5
0
5
0
0
3
5
5
5
3
5
5
5
5
5
5
5
5
5
0
5
5
3
0
5
5
3
3
0
5
5
3
0
0
5
0
3
0
0
3
0
5
5
5
5
5
0
5
5
3
5
0
0
5
5
0
0
0
5
0
0
3
5
5
3
0
5
0
3
5
5
5
0
5
0
5
3
5
...

result:

ok 

Test #21:

score: 16
Accepted
time: 38ms
memory: 3816kb

input:

0
10
4 1000000
0 1
2 3
0 2
4 1000000
2 1
3 1
0 2
4 1000000
3 1
3 0
1 2
4 1000000
1 3
2 1
0 2
4 1000000
1 2
1 3
0 3
4 1000000
1 0
1 2
0 3
4 1000000
3 0
0 2
2 1
4 1000000
0 1
2 0
1 3
4 1000000
2 0
0 1
2 3
4 1000000
2 1
3 0
3 1

output:

4
0
3
7
5
4
0
3
7
6
4
0
3
6
7
4
0
3
7
6
4
0
3
6
7
4
0
5
3
7
4
0
5
7
3
4
0
5
7
3
4
0
7
5
3
4
0
3
6
7

input:

1
66495
7 5 2
0
5
3 7 2
6
7
3 0 1
5
3 0 1
0
3 7 1
0
6 7 1
3
3 0 1
5
5 0 2
0
3
6 3 1
3
6 7 1
3
5 3 1
7
3 0 2
6
7
7 0 2
0
5
7 0 1
0
6 7 1
3
6 0 1
3
7 5 1
0
3 7 2
6
7
3 6 2
6
7
5 7 1
7
5 3 2
0
3
0 6 1
7
0 7 2
3
7
7 0 2
0
3
3 7 1
0
5 3 1
7
7 5 1
0
3 7 2
6
7
3 5 1
0
6 3 1
3
6 3 1
3
5 7 2
0
3
7 0 2
0
3
3 ...

output:

5
7
5
0
0
3
5
0
3
3
7
7
0
0
3
3
0
7
6
7
3
7
7
0
0
7
0
7
0
3
3
0
0
7
0
5
7
5
0
5
3
0
7
3
5
0
7
0
3
5
3
7
3
5
3
5
3
3
7
3
7
7
0
7
0
0
7
6
3
3
3
5
3
0
0
7
7
5
3
7
5
0
3
5
3
3
0
0
3
7
3
3
7
7
3
3
3
0
0
7
0
3
3
5
7
7
7
3
5
3
7
3
0
0
7
3
3
0
3
3
0
7
0
3
0
0
0
7
7
7
0
5
0
5
7
7
5
7
7
7
0
7
0
5
0
5
0
7
0
5
...

result:

ok 

Test #22:

score: 16
Accepted
time: 36ms
memory: 4072kb

input:

0
10
1000 1000000
526 757
286 227
877 883
484 370
847 13
425 107
166 745
276 357
746 21
304 131
462 834
317 58
942 423
375 631
977 908
229 838
549 167
518 60
51 772
419 970
909 386
362 829
470 46
218 986
82 787
919 307
947 691
348 900
233 650
253 762
90 850
144 627
954 103
602 268
187 746
568 992
31...

output:

1000
0
534
1274
1392
1065
1310
1029
1974
126
1752
174
786
330
1340
1809
1917
1391
1251
429
1951
1427
1324
555
1397
1113
963
1716
1907
1958
1890
1596
1924
1851
135
1985
1384
1899
204
1320
657
1372
1092
42
576
696
102
1906
1247
552
858
69
1417
1112
1731
1815
1992
1166
1224
1312
1389
1779
1400
1803
182...

input:

1
50050
549 450 2
114
117
162 165 2
625
626
1596 1231 2
1949
1950
1382 356 2
1563
1564
1662 631 2
1655
1658
1939 758 2
662
665
1943 630 2
1614
1617
583 370 2
1958
1959
1046 1889 2
1811
1812
1218 1854 2
687
690
1107 1757 2
1720
1721
1342 739 2
1643
1644
1223 1976 2
1752
1753
1755 1700 2
1410
1413
107...

output:

117
625
1950
1564
1655
665
1614
1959
1812
687
1721
1644
1753
1413
1868
855
1731
488
1991
264
701
516
1723
1754
1784
1382
180
729
914
1062
396
1456
459
1701
159
1863
1178
1871
276
1473
1939
1842
1489
649
694
1119
609
1691
1619
249
132
1594
673
1899
762
666
1488
939
1027
1315
619
558
926
1852
562
514
...

result:

ok 

Test #23:

score: 16
Accepted
time: 36ms
memory: 4072kb

input:

0
1
1000 1000000
622 589
830 829
709 500
278 363
20 230
963 181
768 29
857 332
787 757
897 285
480 939
855 617
959 84
687 755
667 30
553 1
213 98
987 780
47 851
107 764
130 863
326 832
872 636
85 159
119 330
672 210
134 576
224 282
570 387
53 941
723 69
694 642
707 49
260 390
525 768
78 273
811 220
...

output:

1000
0
1551
672
207
99
963
1654
1353
6
414
1737
464
1714
1679
1515
1611
285
1101
1861
425
138
1311
1992
1467
1722
1850
1923
606
438
1200
585
1068
264
466
1696
1440
1185
1627
1987
276
282
450
1404
1950
1764
1128
168
279
1944
1922
1206
1658
1925
663
1792
1939
1775
1140
1855
378
1802
1813
1773
1972
435...

input:

1
50053
1894 636 2
783
786
1807 1335 2
1044
1047
78 368 2
443
444
1678 900 2
1431
1434
969 1783 2
1832
1833
1461 1293 2
1668
1669
372 1365 2
291
294
852 1855 2
1871
1872
1770 699 2
1155
1158
732 1829 2
1911
1912
362 370 2
321
324
1308 1743 2
1719
1720
1377 39 2
1696
1697
447 1726 2
66
69
1254 1290 2...

output:

783
1047
443
1431
1832
1669
291
1871
1155
1911
321
1720
1697
66
1737
162
12
1491
1497
1897
1920
1086
1741
1041
1035
894
201
1782
395
555
507
1717
1554
1167
1674
1915
1236
1875
1254
376
1762
440
1383
1624
1813
1158
57
1893
471
684
1776
879
1847
1140
642
1652
459
1026
1116
1416
1960
1897
312
410
528
6...

result:

ok 

Test #24:

score: 16
Accepted
time: 0ms
memory: 4080kb

input:

0
10
4 1000000
0 1
1 2
2 3
4 1000000
0 1
1 3
3 2
4 1000000
0 2
2 1
1 3
4 1000000
0 2
2 3
3 1
4 1000000
0 3
3 1
1 2
4 1000000
0 3
3 2
2 1
4 1000000
1 0
0 2
2 3
4 1000000
1 0
0 3
3 2
4 1000000
1 2
2 0
0 3
4 1000000
1 3
3 0
0 2

output:

4
0
7
3
6
4
0
7
6
3
4
0
3
7
6
4
0
6
7
3
4
0
3
6
7
4
0
6
3
7
4
0
3
7
5
4
0
3
5
7
4
0
3
5
7
4
0
3
7
5

input:

1
120
7 6 2
0
3
7 3 2
0
3
7 3 2
0
3
6 3 1
3
3 7 2
6
7
0 3 2
3
7
0 5 2
3
7
0 7 1
7
5 3 1
7
7 3 2
0
5
7 0 2
0
3
3 7 1
0
7 0 2
0
3
3 6 2
6
7
3 5 1
0
0 3 1
7
3 6 2
6
7
3 0 1
5
0 7 2
5
7
0 6 1
7
0 3 1
7
3 7 2
6
7
7 5 2
0
5
6 0 1
3
0 7 2
3
7
6 3 1
3
3 0 2
6
7
6 0 1
3
7 0 1
0
3 6 2
6
7
6 7 1
3
0 3 2
3
7
0 ...

output:

3
3
3
3
7
3
7
7
7
0
0
0
0
6
0
7
6
5
7
7
7
7
5
3
7
3
7
3
0
6
3
3
7
3
0
3
7
5
0
7
7
7
0
7
7
7
3
7
7
7
0
5
6
7
0
7
0
3
0
3
7
7
7
0
5
3
3
7
3
0
3
3
0
5
0
7
0
7
3
3
0
5
6
7
3
7
5
7
0
0
7
5
3
5
0
7
3
0
3
3
6
0
7
5
0
3
7
3
3
7
3
5
3
0
7
7
3
7
7
3

result:

ok 

Test #25:

score: 16
Accepted
time: 0ms
memory: 3788kb

input:

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

output:

6
0
11
3
10
6
9
6
0
11
3
10
9
6
6
0
11
3
6
10
9
6
0
11
3
9
10
6
6
0
11
3
6
9
10
6
0
11
3
9
6
10
6
0
11
10
3
6
9
6
0
11
10
3
9
6
6
0
11
6
3
10
9
6
0
11
9
3
10
6

input:

1
300
10 3 2
3
6
6 10 2
9
10
6 0 2
9
10
6 9 2
9
10
11 9 2
0
3
10 0 2
3
6
11 10 2
0
3
6 11 2
9
10
0 11 1
11
3 9 2
10
11
0 3 1
11
10 9 2
3
6
10 6 2
3
6
3 10 2
10
11
3 6 2
10
11
6 9 2
9
10
6 3 2
9
10
9 0 1
6
9 0 1
6
3 6 2
10
11
11 6 2
0
3
11 0 2
0
3
10 0 2
3
6
6 3 2
9
10
0 6 1
11
0 11 1
11
3 11 2
10
11...

output:

3
10
10
9
3
3
3
10
11
10
11
6
6
10
10
9
10
6
6
10
3
0
3
10
11
11
11
9
10
6
10
10
11
6
10
3
11
10
6
9
6
11
6
6
9
3
11
3
3
11
10
11
3
6
9
3
11
11
10
10
3
6
3
11
11
10
11
10
10
11
11
3
3
11
11
6
6
0
6
11
10
3
10
6
10
3
3
3
3
11
11
6
6
6
11
10
10
11
10
11
11
6
10
11
3
11
11
3
10
0
10
10
10
6
10
11
11
0
...

result:

ok 

Test #26:

score: 16
Accepted
time: 0ms
memory: 4076kb

input:

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

output:

3
0
5
3
3
0
3
5
3
0
3
5

input:

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

output:

5
5
5
5
5
3
0
5
5
0
0
0
0
0
5
3
5
3

result:

ok 

Test #27:

score: 16
Accepted
time: 36ms
memory: 3784kb

input:

0
10
4 1000000
2 1
1 0
3 2
4 1000000
1 2
0 1
1 3
4 1000000
1 0
2 0
0 3
4 1000000
1 3
1 0
2 0
4 1000000
3 2
0 3
3 1
4 1000000
0 1
1 3
2 1
4 1000000
0 1
0 3
3 2
4 1000000
0 3
1 2
0 2
4 1000000
0 2
3 2
2 1
4 1000000
2 0
2 3
0 1

output:

4
0
7
3
6
4
0
7
3
5
4
0
3
5
7
4
0
5
7
3
4
0
5
3
7
4
0
7
5
3
4
0
3
5
7
4
0
5
7
3
4
0
5
7
3
4
0
7
5
3

input:

1
66694
0 5 2
3
7
7 5 2
0
5
3 7 1
7
7 0 3
0
3
5
5 3 1
7
5 3 2
0
3
3 5 1
0
7 5 1
0
3 7 1
7
5 3 1
7
0 5 1
7
5 3 1
7
3 5 1
0
5 7 2
0
3
7 5 3
0
3
5
0 3 1
7
7 3 2
0
5
3 7 1
7
5 0 1
7
3 5 1
7
3 5 1
7
0 6 1
7
3 7 1
7
7 0 3
0
3
5
0 3 1
7
3 0 1
7
3 5 1
7
3 5 1
5
3 0 1
7
5 7 1
7
7 0 3
0
3
5
0 5 2
3
7
5 7 1
7
...

output:

7
5
7
0
7
3
0
0
7
7
7
7
0
0
5
7
0
7
7
7
7
7
7
0
7
7
7
5
7
7
0
7
7
7
0
7
7
5
0
7
7
0
0
0
6
7
5
7
0
3
5
7
7
7
3
0
3
0
7
0
7
7
7
7
7
3
5
7
7
7
7
7
3
7
0
0
7
0
7
0
3
7
7
7
3
5
5
7
0
5
5
7
0
5
7
3
7
7
5
0
3
6
5
7
3
7
0
7
7
0
5
0
7
0
3
3
7
0
0
7
7
0
6
7
7
7
7
7
7
5
7
0
3
7
5
5
7
0
7
0
7
7
7
5
5
5
0
7
7
7
...

result:

ok 

Test #28:

score: 16
Accepted
time: 36ms
memory: 4048kb

input:

0
10
1000 1000000
802 637
810 172
802 781
109 293
802 724
488 524
73 802
802 312
108 985
802 594
305 802
802 620
382 747
841 535
802 690
987 387
269 559
201 219
982 319
228 802
802 977
291 962
657 597
69 757
321 555
825 299
802 694
363 827
802 265
475 796
600 891
802 16
802 116
487 167
150 335
175 5...

output:

1000
0
510
977
1117
1826
1631
1027
646
1802
1886
1989
1349
612
958
756
1340
144
1639
1334
234
880
1012
352
742
1376
889
804
952
202
748
1612
662
1224
738
550
1822
478
572
482
1786
268
47
1266
1165
1843
1252
856
1682
998
182
189
868
1374
165
41
1212
442
628
552
1162
249
62
59
1304
1870
966
1442
1526
...

input:

1
51340
447 1561 2
1356
1357
408 87 2
1877
1878
1162 1039 2
393
396
593 1869 2
662
663
1356 756 2
1561
1562
1138 492 2
1177
1178
1319 24 2
1354
1355
276 1827 2
259
262
1194 1397 1
1196
1402 1367 1
3
210 336 2
1435
1436
1107 465 2
1136
1137
1340 199 2
1367
1368
1382 1861 1
113
1936 1830 2
1923
1926
1...

output:

1357
1878
396
663
1562
1178
1355
259
1196
3
1435
1137
1368
113
1923
1318
725
113
3
1600
1387
1649
750
879
1551
113
1928
700
993
1899
1903
372
311
476
1324
1773
1196
505
1340
1732
1947
1651
50
3
840
53
883
0
1881
465
1292
26
786
1279
558
113
1845
1621
838
1058
1928
3
1883
397
113
74
1185
1354
549
325...

result:

ok 

Test #29:

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

input:

0
10
1000 1000000
1 433
265 863
766 305
237 422
591 33
588 87
33 868
33 328
110 458
718 791
891 33
22 576
773 795
489 357
104 33
33 829
308 726
592 865
651 179
591 508
264 792
274 367
219 33
67 600
419 406
583 183
716 211
4 709
983 33
672 928
648 689
679 497
321 874
711 585
758 518
223 702
440 618
7...

output:

1000
0
1198
1023
855
579
920
765
1428
104
792
1723
1182
341
1436
1739
1152
1549
1916
793
1670
502
1205
1745
643
1939
1174
1027
1936
1324
226
987
1601
869
1996
1545
1046
444
1397
1678
1710
886
1233
710
1726
1348
1513
1756
202
166
729
1013
1795
346
970
280
1328
1831
1890
583
1326
1452
1644
267
1517
48...

input:

1
51513
1711 1490 2
1244
1247
755 65 2
834
835
831 1235 1
1999
971 1489 1
1999
1472 1043 2
1459
1462
967 303 2
974
975
618 1318 2
15
18
835 1528 2
672
675
1224 173 2
1185
1188
981 773 1
1999
1792 918 2
39
42
1810 652 2
1819
1820
1174 1338 2
15
1144
1167 1830 2
1140
1143
1811 1954 2
1280
1283
27 528 ...

output:

1247
835
1999
1999
1459
975
15
672
1185
1999
42
1820
15
1140
1280
1692
1996
1015
1533
509
295
1814
15
1030
1636
1992
1999
1881
100
517
1992
1576
711
1204
1568
1721
1079
501
315
1999
566
647
55
1258
697
1999
89
1999
1674
299
1999
1999
1631
1802
1999
1783
1999
1245
353
1631
976
241
1051
1913
402
1589
...

result:

wrong answer Diff at 24805-th number: read 51 but expected 1996

Subtask #4:

score: 0
Wrong Answer

Test #34:

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

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
0
3
2
0
3
2
0
3
2
0
3
2
0
3
2
0
3
2
0
3
2
0
3
2
0
3
2
0
3

input:

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

output:

0
3
3
0
3
0
0
0
0
0
3
0
3
0
3
3
3
0
0
3
0
3
3
0
0
3
3
0
3
3
0
0
0
0
0
3
0
3
0
0
0
3
3
0
3
3
3
3
0
0
3
3
0
0
0
3
3
0
3
3
0
3
3
0
0
0
3
0
3
3
3
3
3
3
0
3
0
3
3
3
0
0
0
0
3
0
0
3
0
3
3
0
3
3
3
0
0
0
3
3
3
0
3
0
0
3
0
3
0
3
3
0
0
3
0
0
0
3
3
3
0
0
0
3
3
0
0
3
3
3
0
3
0
3
0
3
3
3
3
0
0
0
0
3
0
0
3
0
0
0
...

result:

ok 

Test #35:

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

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
0
3
5
3
0
3
5
3
0
5
3
3
0
3
5
3
0
5
3
3
0
5
3
3
0
3
5
3
0
5
3
3
0
5
3
3
0
3
5

input:

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

output:

3
3
5
5
0
5
5
0
0
3
3
5
3
3
5
5
0
3
5
5
3
3
0
5
5
5
5
0
5
0
3
3
0
5
0
5
0
3
5
0
5
5
0
5
0
0
5
5
0
0
5
3
0
5
5
5
5
5
0
5
3
5
5
3
0
3
0
5
3
5
3
5
5
5
3
5
0
0
0
3
0
0
5
0
0
0
3
5
5
0
5
5
3
3
3
5
3
0
3
5
0
0
5
0
0
3
0
3
5
0
3
5
5
0
5
5
0
5
5
5
5
0
3
3
0
5
5
5
3
0
5
0
5
0
3
5
5
3
5
5
0
5
3
5
0
0
0
5
5
5
...

result:

ok 

Test #36:

score: 10
Accepted
time: 38ms
memory: 4092kb

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
0
7
3
5
4
0
3
6
7
4
0
7
3
5
4
0
7
3
6
4
0
7
6
3
4
0
3
5
7
4
0
3
5
7
4
0
6
7
3
4
0
6
3
7
4
0
7
3
5

input:

1
66804
0 3 2
5
7
0 3 2
5
7
7 0 2
0
5
0 7 1
7
0 5 2
3
7
7 5 2
0
5
3 6 2
6
7
7 3 2
0
3
0 3 1
7
5 7 2
0
3
0 7 2
3
7
7 0 2
0
5
3 7 2
6
7
3 0 1
0
7 0 2
0
3
3 5 1
0
3 0 1
0
7 5 2
0
5
3 7 2
6
7
6 3 1
3
3 6 2
6
7
7 0 1
0
0 7 1
7
7 6 2
0
3
6 3 1
3
7 3 2
0
5
7 0 2
0
3
6 3 1
3
6 3 1
3
0 3 2
3
7
7 5 2
0
5
6 7 ...

output:

5
5
0
7
7
5
6
3
7
0
7
0
7
0
0
0
0
5
7
3
6
0
7
3
3
0
0
3
3
3
5
3
3
0
7
7
7
7
7
3
0
3
7
3
7
0
7
7
7
3
5
5
3
5
5
3
3
7
6
0
7
0
7
5
3
0
7
3
7
7
7
0
7
7
5
0
5
0
0
3
3
7
7
7
0
0
3
7
3
3
0
3
3
0
7
7
7
3
0
7
3
0
6
3
3
7
3
7
7
3
5
0
7
0
0
0
7
3
0
6
7
3
7
7
5
3
3
3
0
7
6
0
7
7
3
7
5
3
5
0
6
7
7
0
0
0
3
0
7
7
...

result:

ok 

Test #37:

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

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
0
7
3
6
4
0
7
6
3
4
0
3
7
6
4
0
6
7
3
4
0
3
6
7
4
0
6
3
7
4
0
3
7
5
4
0
3
5
7
4
0
3
5
7
4
0
3
7
5

input:

1
120
3 7 2
6
7
3 5 1
5
6 3 1
3
0 6 1
7
3 5 1
0
7 3 2
0
3
7 3 1
0
0 3 1
7
0 7 1
7
6 7 1
3
3 0 2
6
7
5 7 1
7
0 7 2
3
7
3 6 2
6
7
7 0 2
0
3
3 7 1
5
3 0 2
6
7
3 0 1
0
6 7 1
3
7 5 1
0
6 7 1
3
0 7 2
5
7
0 7 2
3
7
5 0 1
7
7 0 2
0
3
0 5 2
5
7
6 0 1
3
7 0 2
0
5
3 0 1
5
6 3 1
3
0 6 1
7
7 6 2
0
3
7 3 2
0
3
0 ...

output:

7
5
3
7
0
3
0
7
7
3
7
7
7
6
0
5
7
0
3
0
3
7
7
7
0
5
3
0
5
3
7
3
3
7
7
0
7
7
7
7
7
3
6
3
3
6
7
6
3
3
3
7
0
0
5
0
7
7
3
3
5
7
5
0
6
7
0
7
5
0
3
7
3
0
3
0
3
7
0
3
3
7
7
7
0
0
7
5
3
7
7
3
7
0
3
0
3
7
5
7
3
3
0
3
3
7
3
5
0
7
7
6
0
3
3
7
7
0
5
0

result:

ok 

Test #38:

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

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
0
11
3
10
6
9
6
0
11
3
10
9
6
6
0
11
3
6
10
9
6
0
11
3
9
10
6
6
0
11
3
6
9
10
6
0
11
3
9
6
10
6
0
11
10
3
6
9
6
0
11
10
3
9
6
6
0
11
6
3
10
9
6
0
11
9
3
10
6

input:

1
300
0 9 1
11
11 9 2
0
3
3 11 2
10
11
6 9 2
9
10
10 0 2
3
6
0 11 1
11
11 0 2
0
3
0 11 1
11
0 11 1
11
11 10 2
0
3
10 6 2
3
6
0 6 1
11
9 3 1
6
10 9 2
3
6
0 11 1
11
3 9 2
10
11
0 9 1
11
3 6 2
10
11
0 6 1
11
9 0 1
6
6 11 2
9
10
11 3 2
0
3
3 6 2
10
11
10 11 2
3
6
10 6 2
3
6
11 9 2
0
3
6 3 2
9
10
0 3 1
1...

output:

11
3
11
9
3
11
0
11
11
3
6
11
6
6
11
10
11
10
11
6
10
3
10
3
6
3
10
11
11
3
11
10
0
6
0
6
0
3
6
3
3
3
11
3
9
11
6
10
10
6
11
11
10
6
10
10
11
3
11
10
6
6
6
11
6
11
6
6
6
3
6
6
9
10
10
11
10
11
10
9
3
3
3
11
10
11
11
6
10
10
9
6
6
0
6
10
6
10
6
11
6
3
3
9
3
0
11
10
10
10
10
6
3
10
6
10
11
6
6
6
3
11
...

result:

ok 

Test #39:

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

input:

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

output:

3
0
5
3
3
0
3
5
3
0
3
5

input:

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

output:

3
0
0
5
0
0
5
0
3
3
0
5
5
5
5
5
5
5

result:

ok 

Test #40:

score: 10
Accepted
time: 38ms
memory: 3872kb

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
0
7
5
3
4
0
5
3
7
4
0
7
3
5
4
0
7
3
5
4
0
6
7
3
4
0
3
7
5
4
0
3
7
6
4
0
5
7
3
4
0
3
5
7
4
0
7
3
5

input:

1
66674
3 5 1
5
3 5 1
7
7 3 3
0
3
5
3 5 1
7
7 6 2
0
3
7 3 3
0
3
5
0 3 2
3
7
7 0 3
0
3
5
7 3 3
0
3
5
7 3 2
0
3
6 3 1
3
7 3 2
0
5
0 5 1
7
5 0 1
7
7 3 1
0
7 3 1
0
0 7 1
7
5 7 2
0
3
3 0 1
7
5 3 1
7
3 7 2
6
7
5 3 1
7
5 7 2
0
3
3 7 2
6
7
7 3 1
0
3 6 2
6
7
5 7 1
7
3 5 1
7
5 0 1
7
3 6 2
6
7
0 3 2
5
7
0 5 2
...

output:

5
7
3
7
3
3
3
0
3
3
3
0
7
7
0
0
7
0
7
7
7
7
0
7
0
6
7
7
7
6
5
5
7
5
0
7
0
7
7
7
7
7
7
3
7
5
7
7
7
5
0
0
7
7
0
7
0
7
6
7
3
7
7
7
7
7
0
3
0
5
7
3
7
0
7
5
7
5
0
5
7
7
0
7
0
0
3
0
7
5
0
7
0
5
7
7
7
0
3
7
7
5
7
7
3
7
7
5
3
3
3
5
3
7
7
7
7
0
5
0
7
7
3
5
7
7
7
5
6
5
5
3
0
0
3
7
7
6
7
5
7
0
7
7
7
7
7
7
0
7
...

result:

ok 

Test #41:

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

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
0
3
2
0
3
2
0
3
2
0
3
2
0
3
2
0
3
2
0
3
2
0
3
2
0
3
2
0
3

input:

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

output:

0
0
3
0
3
3
3
0
3
0
0
3
3
0
0
3
3
3
3
0
0
0
0
3
0
3
3
0
0
3
3
3
3
3
0
0
0
0
0
0
3
0
3
3
0
3
0
3
0
3
3
3
0
0
0
0
3
0
0
0
3
0
3
0
0
3
3
0
0
0
3
3
0
3
3
0
0
0
0
3
0
3
3
3
0
3
3
0
0
0
3
3
0
0
0
0
0
3
3
0
3
3
3
0
3
3
0
0
3
3
3
0
3
3
3
0
0
3
3
0
3
0
0
0
0
3
3
0
3
3
3
0
0
3
3
3
0
3
0
3
0
0
0
0
0
0
0
0
0
0
...

result:

ok 

Test #42:

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

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
0
3
5
3
0
3
5
3
0
3
5
3
0
3
5
3
0
3
5
3
0
3
5
3
0
3
5
3
0
3
5
3
0
3
5
3
0
3
5

input:

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

output:

0
0
0
5
0
0
5
0
0
5
0
3
5
5
3
0
0
5
0
0
0
5
5
0
3
0
0
0
0
0
0
5
0
0
0
0
5
3
0
3
0
0
3
0
0
3
5
0
0
3
3
0
0
3
0
3
3
5
0
0
0
3
3
3
3
0
0
5
0
0
5
0
3
5
5
0
0
0
0
0
0
0
5
5
5
0
0
0
0
3
0
0
5
3
0
0
0
0
5
0
0
0
0
0
0
0
5
0
0
0
0
0
3
0
0
0
0
0
0
0
5
0
0
0
0
0
3
5
3
0
3
3
0
5
3
0
3
0
0
0
0
3
3
0
5
0
3
0
5
0
...

result:

ok 

Test #43:

score: 10
Accepted
time: 38ms
memory: 4040kb

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
0
5
7
3
4
0
5
7
3
4
0
5
7
3
4
0
5
7
3
4
0
5
7
3
4
0
5
7
3
4
0
5
7
3
4
0
5
7
3
4
0
5
7
3
4
0
5
7
3

input:

1
66554
5 3 2
0
3
0 3 2
5
7
7 5 1
0
3 5 1
5
7 3 1
0
0 7 2
5
7
3 5 1
5
5 3 2
0
3
7 0 1
0
7 5 1
0
3 5 1
5
3 5 1
5
5 0 2
0
3
5 0 2
0
3
5 7 2
0
3
7 5 1
0
7 5 1
0
5 0 2
0
3
7 3 1
0
0 7 2
5
7
0 3 2
5
7
5 7 2
0
3
5 0 2
0
3
5 3 2
0
3
7 5 1
0
0 3 2
5
7
7 5 1
0
0 3 2
5
7
0 7 2
5
7
0 3 2
5
7
0 3 2
5
7
7 5 1
0
...

output:

3
5
0
5
0
7
5
3
0
0
5
5
0
0
0
0
0
0
0
7
5
0
0
3
0
5
0
5
7
5
5
0
0
0
5
3
5
3
0
0
0
5
0
5
0
5
5
5
0
7
5
0
7
5
0
7
3
5
5
0
0
5
0
0
5
0
0
7
5
5
7
5
5
5
5
7
0
3
0
0
5
5
5
5
3
0
5
5
0
5
5
5
0
0
7
0
0
0
5
5
7
0
5
5
5
0
5
5
5
0
5
5
5
5
5
3
0
0
0
5
7
0
0
5
3
0
0
5
5
0
3
5
5
5
5
0
5
3
5
5
5
0
0
7
0
5
0
0
5
0
...

result:

ok 

Test #44:

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

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
0
9
11
13
7
3
5
7
0
9
11
3
5
7
13
7
0
13
7
9
5
3
11
7
0
13
11
9
3
7
6
7
0
3
6
13
10
8
12
7
0
9
11
13
6
8
3
7
0
5
13
11
9
7
3
7
0
9
13
7
11
5
3
7
0
8
10
13
6
12
3
7
0
13
5
7
9
11
3

input:

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

output:

13
13
0
13
0
7
9
3
13
12
13
13
0
5
9
13
13
3
0
9
0
3
0
5
0
3
13
13
0
13
0
9
13
0
3
0
8
0
5
3
13
10
3
5
9
0
3
0
9
0
3
3
9
0
0
0
3
0
0
3
13
3
0
13
0
0
0
13
5
13
3
0
3
13
3
9
0
13
0
13
3
3
3
9
9
0
0
13
8
13
3
3
13
0
9
7
0
0
9
0
13
13
0
13
0
13
3
0
9
0
0
13
3
11
0
8
7
0
0
0
13
3
7
0
3
5
3
11
0
5
3
3
9
7...

result:

wrong answer Diff at 156-th number: read 6 but expected 13

Subtask #5:

score: 0
Wrong Answer

Test #54:

score: 50
Acceptable Answer
time: 38ms
memory: 4072kb

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
0
5
3
998
0
604
1939
1740
1637
210
1782
1501
1989
892
273
1129
1979
1174
1048
1657
261
192
1483
78
679
363
1723
1817
1810
93
315
1623
1915
1780
1968
1624
1787
1689
907
487
760
1180
1699
1956
18
850
1543
1667
1826
934
1510
1276
484
362
517
114
742
81
412
544
1261
1830
383
403
1909
1084
781
1141
625...

input:

1
59797
3 6 2
6
7
798 939 2
1253
1254
3 0 1
0
164 83 2
131
134
321 1781 2
868
869
7 0 2
0
3
7 6 2
0
3
583 1027 2
1936
1937
1769 1970 2
1658
1661
1779 1704 2
934
937
0 3 1
3
1268 1264 2
753
756
1321 591 2
594
597
1972 1875 2
475
478
5 0 2
0
3
1902 1601 2
565
568
1742 1541 2
771
774
44 65 2
193
194
13...

output:

6
1253
0
131
869
0
3
1936
1658
937
3
756
594
478
0
568
774
193
16
264
1529
0
7
1085
313
1547
1825
1905
1771
3
0
321
418
5
1511
53
141
1860
172
0
5
3
1355
1929
0
1196
1652
939
1058
13
3
159
1250
0
18
1622
1297
3
1889
7
3
811
7
19
900
162
7
1622
348
6
15
1906
297
909
1912
1673
3
1383
1570
1444
5
198
5...

result:

points 0.81967213110 max label = 1999

Test #55:

score: 50
Acceptable Answer
time: 36ms
memory: 4044kb

input:

0
10
997 1000000000
210 799
337 790
66 160
541 810
854 650
948 726
189 923
593 566
649 647
907 215
598 271
78 173
820 920
364 470
435 553
634 846
276 104
203 761
874 954
20 983
946 834
365 933
37 641
811 497
970 551
42 389
59 52
747 45
35 291
534 616
284 677
215 83
741 600
549 680
58 500
495 489
664...

output:

997
0
369
409
623
1418
1923
1667
617
87
1949
1640
168
363
1714
1845
1828
9
1926
1748
1688
1782
501
279
1157
1115
1352
1673
1960
1663
1947
923
1040
1698
641
983
1749
1562
1690
1943
159
1687
1932
851
1768
192
479
1529
797
1421
863
749
228
833
1898
1638
405
1139
1454
1802
1892
477
1762
578
662
1376
190...

input:

1
50045
1338 1578 2
651
654
951 1005 2
1192
1193
911 1591 2
1770
1771
918 504 2
1831
1832
1738 1952 2
1295
1298
1320 894 2
567
570
1272 1023 2
711
714
958 832 2
1805
1806
1011 1927 2
516
519
390 1857 2
1077
1078
1109 1229 2
1704
1705
516 525 2
1337
1338
1368 561 2
1681
1682
1727 1444 2
1192
1195
125...

output:

651
1192
1770
1832
1295
570
714
1806
516
1078
1704
1337
1682
1195
1720
1905
1856
1744
766
1128
1265
473
1483
1782
1403
367
828
1405
429
1801
771
511
378
735
1096
180
195
156
965
944
1121
0
1431
1931
1002
1620
573
1725
1348
1907
551
183
1147
1206
1889
522
1909
339
363
1128
1903
1369
1660
557
989
1831...

result:

points 0.81967213110 max label = 1999

Test #56:

score: 61
Accepted
time: 50ms
memory: 3816kb

input:

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

output:

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

input:

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

output:

3
3
3
0
3
3
3
3
3
3
0
3
0
3
0
0
3
3
0
3
3
3
0
0
0
0
0
0
3
3
0
3
3
3
3
0
3
0
3
3
0
3
0
3
0
3
3
3
3
3
0
3
0
0
3
3
0
3
0
3
3
3
3
3
3
3
3
0
0
0
0
0
0
3
0
3
3
3
3
0
3
0
3
0
3
0
0
0
3
0
0
3
3
3
0
3
0
3
3
0
0
0
0
0
0
0
0
0
3
0
0
0
0
0
0
0
3
0
0
3
0
0
0
0
3
0
3
3
3
3
3
0
3
0
3
0
3
3
3
0
3
0
0
0
0
3
3
3
0
0
...

result:

ok 

Test #57:

score: 61
Accepted
time: 40ms
memory: 3792kb

input:

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

output:

3
0
5
3
3
0
5
3
3
0
5
3
3
0
5
3
3
0
5
3
3
0
3
5
3
0
3
5
3
0
5
3
3
0
5
3
3
0
5
3

input:

1
74928
0 3 1
5
0 3 1
5
5 0 2
0
3
3 5 1
5
3 0 1
5
3 0 1
5
3 5 1
0
3 5 1
5
0 5 2
3
5
5 0 1
0
5 3 1
0
0 5 1
5
3 0 1
5
5 3 2
0
3
5 3 1
0
3 0 1
5
0 3 1
5
0 5 2
3
5
3 0 1
0
3 0 1
0
3 0 1
5
0 5 2
3
5
5 3 2
0
3
0 5 1
5
3 0 1
0
0 3 1
5
0 3 1
5
0 3 1
5
0 5 2
3
5
0 5 1
5
0 3 2
3
5
3 0 1
5
0 5 1
5
3 0 1
5
3 0 ...

output:

5
5
0
5
5
5
0
5
5
0
0
5
5
3
0
5
5
5
0
0
5
5
3
5
0
5
5
5
5
5
3
5
5
5
0
0
5
5
5
3
5
5
0
5
5
5
5
0
5
5
5
0
5
3
0
0
5
5
0
5
5
5
3
5
5
0
5
5
5
5
5
3
5
0
0
5
0
3
0
5
0
0
0
5
5
3
5
5
5
3
0
5
3
3
0
5
0
5
5
0
5
5
0
0
0
3
5
0
5
5
0
5
0
5
0
5
0
0
0
5
3
5
5
5
0
3
3
5
0
5
0
5
0
5
0
3
0
3
3
5
0
0
0
3
0
3
0
5
0
5
...

result:

ok 

Test #58:

score: 61
Accepted
time: 30ms
memory: 3884kb

input:

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

output:

4
0
3
7
6
4
0
7
5
3
4
0
7
3
5
4
0
6
3
7
4
0
3
7
5
4
0
7
3
5
4
0
7
6
3
4
0
5
3
7
4
0
7
6
3
4
0
5
3
7

input:

1
66734
3 0 1
5
3 7 2
6
7
5 3 2
0
3
7 0 2
0
5
5 3 2
0
3
3 0 2
6
7
5 0 2
0
3
3 7 2
6
7
0 3 2
5
7
3 7 1
5
3 0 1
5
0 5 2
5
7
3 5 1
5
0 3 2
5
7
7 3 2
0
5
7 0 1
0
5 7 1
7
6 0 1
3
0 7 1
7
7 6 2
0
3
7 0 2
0
5
3 0 1
5
0 3 2
5
7
7 0 1
0
6 0 1
3
3 0 1
5
7 3 1
0
0 7 1
7
0 7 2
5
7
5 0 2
0
3
5 3 1
7
7 0 2
0
3
3 ...

output:

5
7
3
0
3
7
0
7
5
5
5
5
5
5
0
0
7
3
7
3
0
5
5
0
3
5
0
7
7
0
7
0
7
7
0
3
3
5
0
0
0
5
0
7
3
0
0
0
6
0
5
7
0
3
3
0
7
0
3
0
3
7
7
3
3
0
0
0
3
3
3
3
5
3
0
3
0
3
3
7
0
0
7
3
5
7
3
7
5
5
0
0
3
0
3
0
0
0
0
3
0
7
0
7
3
7
7
0
6
0
5
6
3
5
0
0
0
0
5
0
5
0
5
3
3
3
3
3
0
7
7
7
5
0
7
7
5
0
0
0
3
3
5
0
0
3
6
7
3
5
...

result:

ok 

Test #59:

score: 50
Acceptable Answer
time: 36ms
memory: 3812kb

input:

0
10
1000 1000000000
313 401
316 54
721 11
679 942
681 467
84 472
977 306
285 19
891 45
654 702
294 627
927 124
583 515
700 300
401 460
521 643
911 738
818 7
895 746
370 781
405 64
904 359
22 187
609 408
363 713
768 965
345 943
512 10
149 608
438 998
642 108
680 783
648 653
592 351
79 477
759 16
430...

output:

1000
0
1330
582
1276
1081
1015
1585
672
183
579
1774
1934
84
696
935
1471
1009
1910
1690
802
1912
768
1754
872
1051
441
408
1803
1938
1832
567
156
1633
1785
348
1156
549
1021
772
1312
1978
904
896
1004
1971
234
961
42
1390
1829
1827
942
1363
261
816
1687
504
1426
741
1769
1411
1778
1231
1006
390
191...

input:

1
50038
1019 1776 2
1782
1783
1143 1771 2
1786
1787
1866 774 2
123
126
1377 1600 2
1540
1541
501 1942 2
1740
1741
1548 1179 2
1077
1080
1724 1855 2
1627
1630
840 1925 2
1781
1782
633 564 2
1850
1851
1946 90 2
1165
1168
1060 618 2
1981
1982
1786 1982 2
1007
1010
1640 1837 2
1705
1706
1843 1550 2
468
...

output:

1782
1786
126
1541
1741
1080
1627
1782
1851
1165
1982
1007
1706
471
492
36
405
1437
1786
1749
1855
1741
534
456
1602
632
240
1996
69
1666
348
1324
622
1843
1643
1795
1400
1780
471
1796
975
525
1730
1344
600
813
180
447
1786
1995
144
1361
1833
174
189
1891
1458
1806
1149
1550
646
462
1546
1851
567
12...

result:

points 0.81967213110 max label = 1999

Test #60:

score: 50
Acceptable Answer
time: 28ms
memory: 3788kb

input:

0
1
1000 1000000000
165 608
217 371
579 924
67 365
865 568
258 7
999 657
669 881
268 354
140 308
76 139
428 750
616 661
178 737
179 1
705 411
437 759
119 472
353 50
549 581
327 276
319 864
662 404
619 776
651 890
153 938
580 396
501 193
560 607
786 871
291 760
898 722
511 542
743 74
742 918
431 774
...

output:

1000
0
1089
1036
87
1750
564
597
1107
1600
1988
1759
989
994
525
300
1979
1402
1252
1082
907
1011
1849
375
1063
678
1035
1890
555
1531
495
471
15
1735
435
869
1663
399
474
393
1630
1937
852
675
1863
1050
1108
1905
892
1087
991
1327
1779
1952
1459
192
924
21
312
1910
1132
952
1935
1899
1495
968
1040
...

input:

1
50048
1108 105 2
21
24
1888 862 2
1447
1450
948 1980 2
501
504
917 1103 2
594
597
1126 714 2
1995
1996
904 873 2
633
636
1387 1086 2
1908
1909
60 1852 2
1095
1096
6 844 2
1113
1114
1279 1540 2
1944
1945
1023 1782 2
276
279
916 1237 2
597
600
1342 992 2
1923
1924
1015 1726 2
300
303
852 708 2
789
7...

output:

24
1447
501
594
1996
636
1909
1096
1113
1944
276
597
1924
300
789
932
1034
594
1935
1838
666
342
1815
1306
3
738
114
909
1744
859
660
1934
1923
1058
1567
822
1004
1020
1711
1897
1800
1970
1570
1507
945
850
1633
1366
1375
1910
930
1053
294
1818
949
1240
762
378
1871
75
342
1477
255
162
1420
1393
1986...

result:

points 0.81967213110 max label = 1999

Test #61:

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

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
0
7
3
6
4
0
7
6
3
4
0
3
7
6
4
0
6
7
3
4
0
3
6
7
4
0
6
3
7
4
0
3
7
5
4
0
3
5
7
4
0
3
5
7
4
0
3
7
5

input:

1
120
5 3 1
7
7 6 2
0
3
6 7 1
3
0 3 1
7
6 7 1
3
0 7 2
5
7
7 3 2
0
3
5 3 2
0
3
3 0 1
0
6 0 1
3
0 6 1
7
3 7 2
6
7
7 3 2
0
3
7 3 2
0
5
0 7 1
7
7 0 2
0
3
0 7 1
7
3 0 2
6
7
7 0 1
0
0 6 1
7
0 5 2
5
7
3 7 1
0
0 3 1
7
0 3 1
7
3 5 1
0
3 0 1
5
5 0 2
0
3
7 3 2
0
5
3 6 2
6
7
0 3 2
3
7
7 6 2
0
3
6 3 1
3
3 5 1
0
...

output:

7
3
3
7
3
7
3
3
0
3
7
7
3
0
7
0
7
7
0
7
5
0
7
7
0
5
0
0
6
3
3
3
0
6
5
7
3
3
3
7
7
3
0
3
0
3
3
7
3
7
7
0
7
5
5
0
7
0
7
5
7
7
0
3
0
7
0
3
6
5
5
7
3
0
3
3
3
7
7
3
7
7
6
0
7
3
5
3
3
5
0
5
7
3
6
7
7
3
7
7
7
3
3
6
3
7
7
7
0
0
0
7
7
0
3
0
7
7
5
0

result:

ok 

Test #62:

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

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
0
11
3
10
6
9
6
0
11
3
10
9
6
6
0
11
3
6
10
9
6
0
11
3
9
10
6
6
0
11
3
6
9
10
6
0
11
3
9
6
10
6
0
11
10
3
6
9
6
0
11
10
3
9
6
6
0
11
6
3
10
9
6
0
11
9
3
10
6

input:

1
300
0 10 1
11
6 11 2
9
10
11 10 2
0
3
3 0 2
10
11
0 9 1
11
9 3 1
6
6 3 2
9
10
11 10 2
0
3
9 10 1
6
6 0 2
9
10
0 3 1
11
6 0 2
9
10
6 0 2
9
10
11 6 2
0
3
3 6 2
10
11
6 0 2
9
10
9 11 1
6
6 9 2
9
10
3 11 2
10
11
3 11 2
10
11
6 0 2
9
10
9 6 1
6
0 6 1
11
0 10 1
11
0 3 1
11
11 9 2
0
3
0 9 1
11
9 0 1
6
3 ...

output:

11
10
3
11
11
6
10
3
6
10
11
10
10
3
10
10
6
9
11
11
10
6
11
11
11
3
11
6
11
10
6
10
3
11
10
6
10
6
11
11
10
6
11
6
6
0
3
6
0
10
11
11
3
11
10
3
3
6
3
3
10
10
11
11
3
3
3
3
0
3
10
6
9
11
3
3
11
10
6
6
0
6
11
10
6
3
3
3
11
10
6
6
6
10
10
6
10
3
6
6
11
6
6
10
6
3
3
6
10
6
9
6
3
10
11
6
11
6
11
6
10
6
...

result:

ok 

Test #63:

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

input:

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

output:

3
0
5
3
3
0
3
5
3
0
3
5

input:

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

output:

0
0
3
5
5
5
3
0
5
0
3
0
5
5
5
5
5
0

result:

ok 

Test #64:

score: 0
Wrong Answer
time: 34ms
memory: 3812kb

input:

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

output:

997
0
1023
1993
3
513
1025
1535
258
512
768
1022
1280
1534
1790
1992
6
132
260
386
516
642
770
896
1028
1154
1282
1408
1538
1664
1792
1918
69
131
195
257
323
385
449
511
579
641
705
767
833
895
959
1021
1091
1153
1217
1279
1345
1407
1471
1533
1601
1663
1727
1789
1855
1917
1961
1991
9
39
71
101
135
1...

input:

1
49888
1411 785 3
1426
1440
1471
363 746 1
358
1547 411 1
1544
1499 802 1
1496
946 1383 3
949
951
958
959 1597 3
896
899
929
445 1639 1
442
1921 1138 3
1936
1946
1961
1895 569 1
1890
1084 1866 3
1087
1089
1090
984 289 3
987
989
990
1166 173 3
1169
1171
1172
1785 793 1
1782
1664 668 3
1727
1789
1790...

output:

1471
358
1544
1496
958
896
442
1961
1890
1090
990
1172
1782
1790
1288
1720
964
69
914
42
1008
833
1964
1880
611
1496
1408
1825
1140
1792
340
1960
548
131
1910
480
902
1788
1025
480
922
1571
384
1364
370
1028
1541
138
385
342
1338
1160
490
1752
752
596
864
1123
1376
1187
1146
354
895
1921
730
1294
17...

result:

wrong answer Diff at 7305-th number: read 981 but expected 990