QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#293122#1884. Mission Impossible: Grand Theft AutoYuJiaheAC ✓84ms31744kbC++232.6kb2023-12-28 21:55:452023-12-28 21:55:45

Judging History

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

  • [2023-12-28 21:55:45]
  • 评测
  • 测评结果:AC
  • 用时:84ms
  • 内存:31744kb
  • [2023-12-28 21:55:45]
  • 提交

answer

#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;
class edge{
	public:
		edge(int x, int y, int z, int zz){v = x, w = y, c = z, nxt = zz;}
		int v, w, c, nxt;
};
class graph{
	private:
		vector<int> head;vector<edge> e;
	public:
		void init(int n){head.clear(), e.clear();for (int i = 0;i <= n;i ++) head.emplace_back(-1);}
		graph(){}graph(int n){init(n);}
		inline int addedge(int u, int v, int w = 0, int c = 0){e.emplace_back(v, w, c, head[u]), head[u] = e.size() - 1;return e.size() - 1;}
		inline int add2edge(int u, int v, int w = 0){int tmp = addedge(u, v, w);addedge(v, u, w);return tmp;}
		inline int addfedge(int u, int v, int w, int c = 0){int tmp = addedge(u, v, w, c);addedge(v, u, 0, -c);return tmp;}
		inline int& h(int u){return head[u];}
		inline edge& operator[](int i){return e[i];}
}G;
const int N = 200005;vector<int> to[N], ed[N];
int t, n, m, a[N], d[N], L[N], R[N], rt, p;
void su2(int u, int fa, int tp){
	if (d[u] != 2){if (tp) to[tp].push_back(u);tp = u;}
	for (int i = G.h(u);i != -1;i = G[i].nxt){
		int v = G[i].v;if (v != fa) su2(v, u, tp);
	}
}
void dfs1(int u){L[u] = m + 1;
	if (d[u] == 1) a[++ m] = u;
	for (int v : to[u]) dfs1(v);R[u] = m;
}
void dfs2(int u){int mid = L[u] + R[u] >> 1;if (u != rt){
	if (m & 1) ed[R[u] - L[u] & 1 ? mid : (mid + m / 2 - 1) % m + 1].push_back(u);
	else if (R[u] - L[u] & 1) ed[mid].push_back(u), ed[(mid + m / 2 - 1) % m + 1].push_back(u);}
	for (int v : to[u]) dfs2(v);
}
int main(){scanf("%d", &t);
	while (t --){scanf("%d", &n), G.init(n), rt = p = 1, m = 0;
		for (int i = 1;i <= n;i ++) to[i].clear(), ed[i].clear(), d[i] = 0;
		for (int i = 1, u, v;i < n;i ++)
		scanf("%d%d", &u, &v), G.add2edge(u, v), d[u] ++, d[v] ++;
		while (rt <= n && d[rt] < 3) rt ++;
		if (rt > n){int x = 0, y = 0;
			for (int i = 1;i <= n;i ++)
			if (d[i] == 1) (x ? y : x) = i;
			printf("%d %d\n%d %d\n", x, y, x, y);continue;
		}su2(rt, 0, 0), dfs1(rt), dfs2(rt);
		while (ed[p].size() > 1) p ++;
		if (ed[p].empty()){
			for (int l = p, r = p + 1, c = m / 2;c --;){
				l = l ? l : m, r = r <= m ? r : 1;
				printf("%d %d\n", a[l], a[r]), l --, r ++;
			}printf("1 2\n");continue;
		}bool flg = 0;
		int ls = L[ed[p][0]], rs = R[ed[p][0]];
		int u = a[L[ed[p][0]]], v = a[L[ed[p][0]] == 1 ? m : 1];
		for (int l = p + 1, r = p, c = m / 2;c --;){
			l --, r ++, l = l ? l : m, r = r <= m ? r : 1;
			if (l == rs && r == ls) printf("%d %d\n", u, v), flg = 1;
			printf("%d %d\n", a[l], a[r]);
			if (l == ls && r == rs) printf("%d %d\n", u, v), flg = 1;
		}if (!flg) printf("%d %d\n", u, v);
	}
}

详细

Test #1:

score: 100
Accepted
time: 5ms
memory: 12548kb

input:

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

output:

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

result:

ok All OK (4 test cases)

Test #2:

score: 0
Accepted
time: 29ms
memory: 13380kb

input:

100
2000
494 1815
316 280
704 103
1627 787
475 1616
401 744
1003 1901
46 66
428 1703
1865 450
1645 852
146 1488
469 1825
104 332
1638 1941
127 468
1558 350
373 1492
1287 1809
76 1479
1653 1243
1292 1465
922 1497
1891 459
1347 176
1996 1377
1182 1570
1461 742
1972 984
355 1412
650 338
1708 121
1869 1...

output:

948 1361
1128 361
1559 925
1167 916
716 1587
679 1414
385 901
540 1270
319 328
1290 1767
1409 1225
99 702
735 1296
9 810
1579 1730
1834 980
1683 1648
1679 1515
496 1143
402 1764
64 1773
403 1284
1855 1096
147 1760
819 1636
158 1591
698 683
1594 406
533 165
1267 473
1613 1976
572 1742
1844 672
168 66...

result:

ok All OK (100 test cases)

Test #3:

score: 0
Accepted
time: 35ms
memory: 13504kb

input:

100
2000
1312 1335
1335 1706
1913 1335
1335 896
1335 990
892 1335
1592 1335
1335 213
808 1228
1228 999
1335 332
1430 1335
1335 145
1335 901
1335 1269
1335 564
1335 843
1335 138
493 1335
1707 1335
1335 1368
754 1335
293 1335
1095 1335
355 1335
341 1335
37 1335
1335 1881
1455 1335
605 1335
1335 1322
1...

output:

1292 1649
808 147
999 655
1926 1237
128 677
399 1157
1809 1127
1371 1618
1172 1928
700 1719
458 792
697 579
1862 1779
587 1252
1921 1291
760 490
292 518
1967 335
1493 818
1523 1105
1265 380
1824 186
1901 631
768 1548
485 442
302 1381
1312 661
1706 787
1913 1109
896 691
990 146
892 1916
1592 950
213 ...

result:

ok All OK (100 test cases)

Test #4:

score: 0
Accepted
time: 20ms
memory: 12552kb

input:

100
2000
478 1228
1201 702
874 1106
1043 1608
1010 1698
485 1592
1760 365
369 190
1268 104
250 1182
1530 1793
825 1236
1245 260
1818 551
626 652
979 1565
161 624
1302 1163
1109 1065
353 1342
1181 696
56 1061
905 396
411 1769
671 1715
1487 1906
761 1975
292 346
1889 175
527 1717
965 1780
1296 97
992 ...

output:

344 713
344 713
401 1059
401 1059
289 1569
289 1569
1072 1845
1072 1845
498 584
498 584
625 832
625 832
400 1656
400 1656
252 631
252 631
297 1451
297 1451
540 1379
540 1379
920 1475
920 1475
1598 1613
1598 1613
853 1645
853 1645
137 908
137 908
140 1204
140 1204
454 1460
454 1460
1496 1678
1496 167...

result:

ok All OK (100 test cases)

Test #5:

score: 0
Accepted
time: 29ms
memory: 13072kb

input:

100
2000
1631 317
85 1099
180 616
35 1047
1478 164
1433 959
410 1733
371 1716
1885 1962
217 433
981 872
564 942
1370 655
142 718
1513 1897
1694 683
373 686
1965 833
384 1195
1430 1316
770 787
1456 292
831 166
834 1221
288 716
252 311
1974 1497
391 1603
675 369
542 141
1542 225
741 558
1762 1612
701 ...

output:

843 1403
1292 865
747 1567
136 1203
1506 1512
163 366
645 1274
1745 1307
1188 1372
803 1258
1628 1734
1725 1653
148 1321
735 678
620 1325
651 1410
1683 1464
250 1541
168 1346
513 1125
702 855
157 1498
1434 106
476 1247
963 1952
167 1272
916 1009
1157 615
419 1822
367 1667
1136 1960
355 1436
1174 188...

result:

ok All OK (100 test cases)

Test #6:

score: 0
Accepted
time: 27ms
memory: 12772kb

input:

100
2000
409 1935
85 1581
372 298
566 1538
462 1618
953 1566
1800 1220
1394 1061
553 318
1961 455
1318 168
935 339
1221 352
758 1219
1285 1093
889 948
1808 1849
446 801
1123 623
562 289
1923 5
1061 1276
618 523
865 1287
1143 1708
285 542
1545 1439
1350 72
2 999
956 1197
36 931
35 840
733 352
1481 39...

output:

1506 1001
353 258
857 69
431 1746
244 1944
1748 3
1032 190
1595 24
68 1074
525 1242
566 1384
1692 104
1842 16
332 663
272 1633
96 1440
604 1511
1925 174
674 217
1062 135
557 1415
498 1306
128 420
172 773
1392 1383
214 63
1790 1079
369 1071
1616 1602
1771 1467
1905 1373
1279 677
1658 752
1388 1639
17...

result:

ok All OK (100 test cases)

Test #7:

score: 0
Accepted
time: 34ms
memory: 12836kb

input:

100
2000
360 1067
1071 386
1972 39
630 1817
68 777
91 353
683 1737
657 724
646 448
665 630
337 267
1274 769
977 1075
1177 93
122 1181
302 358
807 1078
1593 428
1301 563
485 1656
64 395
156 628
957 998
516 671
1809 556
765 1143
568 62
585 80
278 1533
38 373
593 1051
614 1262
929 1341
840 52
68 871
11...

output:

1419 1536
1747 1504
1969 1370
1750 1787
1333 1511
1459 1557
1946 1828
1493 1784
1874 1175
1383 1583
1813 1540
1688 1485
1961 1141
1915 1895
1601 1434
1218 1884
1643 1972
1263 1367
1913 1281
1737 1200
1535 1585
1533 1255
1731 1588
1617 1907
1323 1422
1302 1771
1841 1691
1753 1596
1767 1179
1309 1216
...

result:

ok All OK (100 test cases)

Test #8:

score: 0
Accepted
time: 84ms
memory: 27984kb

input:

1
200000
180867 117149
64957 96383
113663 34055
126334 46258
198365 156064
185941 135514
50922 102839
194187 170033
14353 188814
90500 114303
110852 84786
31360 45707
95366 181909
148219 102709
159594 15576
168829 128189
45621 36147
188648 157263
128090 120720
127728 147491
14102 46730
33752 29598
6...

output:

129599 147917
52093 157584
124387 110481
198852 160803
27911 73595
144143 42587
172578 119197
145511 141619
149070 101167
23611 76770
13784 81566
93270 141560
14583 59994
126806 140824
194388 171547
60775 112874
188852 73364
73691 141742
137178 63437
177427 99115
122674 93351
126661 153810
53879 169...

result:

ok All OK (1 test case)

Test #9:

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

input:

1
200000
57440 116519
190896 104071
53012 156570
169755 24088
100818 109488
68779 96300
13283 199209
78123 93290
132729 23440
24264 45870
149108 173718
111047 115843
65821 56899
148506 51951
89726 142789
25286 193684
68947 178839
187345 179659
4349 165429
4425 40651
170136 128767
79833 30317
146012 ...

output:

82187 48443
97533 130620
154882 60922
145849 44678
42747 80561
46941 181197
189970 60262
115010 189955
15195 151360
199876 188703
53214 123516
90107 81857
53697 72220
193252 189921
143587 186308
119733 138707
149012 31699
186024 189664
39320 46720
159004 143584
81321 188017
76498 143374
112221 59615...

result:

ok All OK (1 test case)

Test #10:

score: 0
Accepted
time: 43ms
memory: 29284kb

input:

1
200000
135363 12419
12419 53087
12419 102176
12419 88147
12419 195924
12419 70946
12419 28021
12419 158923
143022 12419
12419 94981
111088 12419
12419 15202
12419 46491
128055 12419
12419 36839
167823 12419
12419 139603
12419 78361
85762 12419
117686 12419
88163 12419
153517 12419
72620 12419
5023...

output:

61482 55565
135363 10395
53087 159108
102176 139212
88147 198981
195924 105173
70946 176731
28021 197124
158923 80843
143022 48685
94981 71004
111088 154496
15202 160885
46491 41693
128055 100335
36839 189246
167823 138844
139603 137960
78361 154791
85762 22212
117686 175704
88163 37850
153517 99187...

result:

ok All OK (1 test case)

Test #11:

score: 0
Accepted
time: 31ms
memory: 22008kb

input:

1
200000
135705 108920
162642 126519
85128 45728
194271 180875
30763 93992
52969 151747
177074 20263
186614 109737
36694 190088
187500 16286
142641 75314
64550 33705
164299 102609
157504 28107
33788 158382
126297 44905
99420 168255
156403 81775
79011 196380
131864 94044
69591 100898
128825 102920
90...

output:

114579 132040
114579 132040

result:

ok All OK (1 test case)

Test #12:

score: 0
Accepted
time: 65ms
memory: 31744kb

input:

1
200000
165592 104127
37950 12293
64975 97946
93785 166716
164318 69986
196751 90865
23447 160715
54234 71862
85060 175999
184004 138041
150985 163147
85042 49367
159900 58574
85526 126934
144113 74917
11820 71982
98279 154765
15130 123668
24221 153534
45841 90041
76611 84919
102872 179527
184300 2...

output:

29188 62259
37245 162172
125389 157978
138733 65132
12911 147712
194711 144213
19557 43831
31728 55324
133315 197350
121630 12168
27278 140166
51446 179985
185013 30268
135738 181808
45925 84585
197661 164357
163484 27161
29200 57172
24575 5505
133252 73202
42054 104580
50328 96693
83958 97987
74750...

result:

ok All OK (1 test case)

Test #13:

score: 0
Accepted
time: 82ms
memory: 27516kb

input:

1
200000
11163 181049
198878 80756
126047 10444
12318 170212
53148 108157
36484 184447
112205 28414
134930 72219
20670 20296
192695 128565
76596 10779
157783 84654
92158 63822
184965 173701
167017 53897
149981 198928
90046 175838
111705 34219
68811 89794
177259 199009
17328 121104
29446 68600
72687 ...

output:

65574 100638
72103 65574
159888 72103
175114 97141
172669 25373
62308 148298
17780 85566
3794 107535
60520 62053
114536 173688
92959 7114
163100 147021
35807 134882
128276 59776
164282 179240
41807 199572
174606 192210
66344 58911
184748 121384
103703 5277
120483 23226
81992 149891
71824 3580
13829 ...

result:

ok All OK (1 test case)

Test #14:

score: 0
Accepted
time: 58ms
memory: 27124kb

input:

1
200000
4575 157468
164012 29131
19086 4026
40781 82891
37731 171364
63302 48036
74202 63605
197957 9856
13617 144515
52209 38724
21317 198083
80992 109217
166602 47381
33797 138331
25902 180272
167967 4317
61778 14894
56463 176107
190512 68141
73749 194304
28584 199885
34348 147657
17957 34484
492...

output:

147287 187107
145206 120679
189189 103614
138231 136643
167464 105916
107776 112046
168564 123312
105331 157898
134094 199333
134501 96441
157270 115486
101533 107882
135701 130391
163238 194013
188506 134336
99462 163485
183899 108318
139574 134671
148203 155007
98146 166633
139941 112796
123793 15...

result:

ok All OK (1 test case)

Test #15:

score: 0
Accepted
time: 40ms
memory: 14884kb

input:

10
20000
16695 1396
13278 3074
12587 14482
7700 15666
17027 19304
8306 4095
18254 12845
3902 15666
14183 1654
4204 14818
17061 8366
4939 9287
10390 13577
18352 7584
2963 12724
16669 3812
11375 11829
1776 12158
13184 13187
4759 587
19649 6559
14340 18587
10756 18874
8109 5657
1744 9320
5211 2432
8530...

output:

17989 16812
18287 15729
17555 14819
8059 17456
1242 9247
162 6853
12977 1002
13818 13362
1505 18502
18382 11917
6961 17319
1687 2709
19610 15279
18153 13347
5051 19989
1770 5817
16095 5453
14614 18781
12892 15651
2825 1627
2643 9994
504 6132
3054 1310
12732 2454
8458 13907
10498 19456
13009 14483
12...

result:

ok All OK (10 test cases)

Test #16:

score: 0
Accepted
time: 19ms
memory: 13280kb

input:

10
20000
2348 3282
5666 6279
5192 9950
18034 567
7661 12644
174 3177
4119 2354
9049 17783
16454 17069
18214 8601
17570 12771
10226 14634
14460 9186
4607 15080
12090 9391
5717 14991
12948 9659
5416 18709
19886 14470
12463 15501
17018 11949
11693 15997
8454 18550
403 2082
14833 18785
11044 11985
16832...

output:

13417 16821
13417 16821
3531 12180
3531 12180
5855 16588
5855 16588
11685 14039
11685 14039
9995 17242
9995 17242
2902 14871
2902 14871
654 8286
654 8286
5659 14901
5659 14901
6997 19044
6997 19044
5298 14536
5298 14536

result:

ok All OK (10 test cases)

Test #17:

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

input:

10
20000
10174 13411
3604 8329
19065 11752
9275 11429
5176 4143
7231 7102
10510 4779
7622 17899
13285 10649
537 13311
12745 6710
7318 15748
3795 6401
4566 18704
2280 9793
10628 15036
2979 4111
5315 2728
15154 5630
10512 9624
4389 1280
15002 1310
17714 11820
14385 16888
8595 11794
15253 6282
15438 78...

output:

8526 16481
8240 14979
18315 5766
2364 18849
501 18851
7707 7209
12092 5621
15375 7028
7317 19017
15923 12025
10383 14719
8729 17046
1132 3039
17209 113
11213 12466
18716 15497
15222 18104
2057 17541
10783 15593
8585 5543
12944 10773
17602 11807
14627 14612
5643 18565
10620 11205
8298 16241
14412 116...

result:

ok All OK (10 test cases)

Test #18:

score: 0
Accepted
time: 37ms
memory: 14060kb

input:

10
20000
6546 12178
8132 12698
9866 18394
4178 19311
18441 13775
13427 19385
9035 5234
18814 5897
13260 16823
240 19280
6194 12827
4971 193
12542 18512
18421 10994
1982 7222
17769 11520
19515 3324
7202 1207
11012 5144
9602 8684
11427 18573
4797 3230
10966 16392
331 4055
1990 9346
13 16133
12222 1776...

output:

11741 10470
11741 15330
15330 1049
15344 1176
10474 4548
4966 4180
17140 5206
6509 4232
1122 962
15284 14962
1504 11102
17506 8262
11511 10750
16915 14127
6541 19622
1672 11872
18814 8291
8562 1514
4682 17285
13939 7131
10182 9286
6144 17121
1756 12945
4953 16854
11529 19476
16757 3719
10152 1101
12...

result:

ok All OK (10 test cases)

Test #19:

score: 0
Accepted
time: 40ms
memory: 14492kb

input:

10
20000
18936 14226
19263 5838
8618 484
11997 12065
7555 4853
11170 19861
10053 8023
4674 1225
5681 11205
15958 2512
19545 13874
13344 14575
12557 12982
62 18520
4294 6383
14307 12269
9064 3353
12435 8926
5232 17514
2223 12758
16561 9385
15839 3786
5596 10714
2554 2704
7760 824
4795 4020
2501 9033
...

output:

17079 16208
16031 19255
17637 17404
16876 15362
15982 18418
19537 15338
17955 17031
16167 19687
15970 19776
15146 19669
15669 18912
18189 18342
18071 16042
18791 19605
18821 18154
15179 17938
17902 17672
16550 19007
15921 16530
16689 16888
15303 18751
19282 18429
15756 19281
19966 15784
16264 16487
...

result:

ok All OK (10 test cases)

Test #20:

score: 0
Accepted
time: 25ms
memory: 14628kb

input:

10
11312
7739 10213
4181 1027
4170 7024
9225 10206
3822 145
3713 8243
8815 1327
9962 736
318 1662
8562 48
9326 1002
5043 6009
928 8908
3571 837
10470 5661
3748 5909
1152 187
9538 2676
10704 8317
10457 4962
6777 9326
4163 4816
9384 6962
10183 531
4923 10222
9244 1092
10966 4894
8100 2154
10098 10331
...

output:

2005 8173
7123 5818
10647 3690
5064 101
2253 11300
770 7688
2425 8451
1805 7372
10356 6061
1070 6690
10006 272
2235 4068
9384 9955
2890 8036
11212 6995
6646 844
6795 10071
409 6258
2058 10749
1475 10835
290 403
5587 2999
936 4734
4459 9088
2062 1247
8343 6611
745 5741
755 329
3866 3799
8651 8830
216...

result:

ok All OK (10 test cases)

Test #21:

score: 0
Accepted
time: 28ms
memory: 14456kb

input:

10
13449
12764 12936
5002 12959
8845 11434
4091 11415
4894 5002
5002 10608
8931 11149
5002 12709
9384 5473
690 8789
6033 4091
9384 6638
3921 853
9961 2907
3844 8931
7903 5040
4091 12458
8931 5188
5002 434
11434 3951
9380 11136
2487 8789
1878 8789
8931 12432
11095 11860
9380 9963
5457 9384
1460 3160
...

output:

4618 10800
10560 7111
10170 11994
2763 13310
4586 1909
7670 8674
6591 6083
7420 12190
10325 6861
12334 11605
1966 2985
10696 12180
11311 10479
7331 10939
6822 11925
13054 2046
10976 3037
10612 6605
13380 8769
7441 10129
7010 11532
8584 6076
8135 4065
605 1769
2064 12913
6174 11118
607 5842
9228 7324...

result:

ok All OK (10 test cases)

Test #22:

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

input:

10
14493
1833 13275
4628 13795
12867 5331
6564 9403
2075 824
4339 8792
7565 7906
3377 4104
4897 11749
4166 279
8310 8908
7842 11805
12951 8243
1363 10049
10426 6105
9824 3042
13787 4927
10620 13711
1528 8158
3726 7386
10532 13174
7863 5049
2000 10370
8750 10724
13438 11506
9107 1969
8538 9710
12047 ...

output:

2864 8179
2864 8179
3471 12882
3471 12882
5072 14829
5072 14829
8734 17332
8734 17332
156 8474
156 8474
13894 18999
13894 18999
1990 6687
1990 6687
292 7642
292 7642
56 7508
56 7508
4697 8655
4697 8655

result:

ok All OK (10 test cases)

Test #23:

score: 0
Accepted
time: 29ms
memory: 14924kb

input:

10
14128
4498 9745
468 10727
4183 2924
10397 10422
1609 3728
10527 7958
5257 11781
7375 7137
13836 9986
7752 10497
13775 5728
5447 5105
6533 1593
9563 6546
7393 5921
9997 4083
11092 6797
13298 4550
13289 13066
4846 12542
4781 9790
11309 12700
1777 205
3315 1167
8709 13799
10721 12965
10146 7479
4004...

output:

1292 9225
9148 10391
7728 3651
9124 2996
11457 2454
12048 4576
4269 13622
12410 6532
12596 7092
13145 4433
2766 9156
7569 4825
7581 318
1304 13446
3632 11246
11282 2666
11528 13135
2056 3404
438 7420
5282 3609
5124 9038
809 4718
10002 4514
2813 4505
6673 11190
824 410
11121 8528
3326 187
6247 1354
4...

result:

ok All OK (10 test cases)

Test #24:

score: 0
Accepted
time: 29ms
memory: 13872kb

input:

10
14665
1098 13101
7459 8501
3771 4992
6274 13209
9606 1624
2135 2263
5347 1754
14289 503
10856 301
8122 3811
3486 4024
9088 13875
1278 5408
5225 11456
5308 1475
2986 11799
9520 13971
12003 4141
3747 7910
1139 3798
11481 864
9160 7180
388 12570
7448 9300
4447 4504
6907 8665
11666 12682
11943 12211
...

output:

3615 9886
3615 1955
1955 8582
11768 6840
9630 1078
10865 1802
11904 2939
1642 1732
1062 10283
14295 9461
3659 1759
10651 10849
6343 13139
1787 477
1910 7518
5929 11209
13729 10313
9558 12930
3038 163
14585 9102
2177 1699
9212 12180
5554 5176
11080 6633
12795 13556
13536 3194
2675 4902
9073 7053
8601...

result:

ok All OK (10 test cases)

Test #25:

score: 0
Accepted
time: 27ms
memory: 13908kb

input:

10
14823
13851 10092
4469 5824
10539 681
5633 4009
11591 2052
9154 2692
2257 4439
7270 391
8135 8998
10371 6008
7953 1123
1917 13346
4253 8134
3141 13970
7216 8485
7217 8044
11904 9026
6879 6256
1758 5875
9127 13292
9266 3451
9418 956
5396 4746
12136 13171
438 5174
4770 8211
4249 10630
11931 7668
30...

output:

13937 14685
13174 13553
14693 14344
12905 13872
14526 13234
13000 12787
13922 14587
13971 14416
13394 13284
12721 13841
13491 14469
12672 14498
13696 13447
13530 12888
13565 14590
13323 14631
14420 13362
13691 13360
14649 14209
13387 14566
13517 13274
12995 12749
14326 13293
13124 13127
13386 13541
...

result:

ok All OK (10 test cases)

Test #26:

score: 0
Accepted
time: 26ms
memory: 13372kb

input:

10
17485
5940 14053
2276 5018
8057 1985
12859 3478
12866 1646
5885 12915
15736 3531
17200 2938
6878 13777
10761 6120
4713 14167
2618 16233
5813 6420
13393 4642
9632 2985
1342 16025
16026 6844
6319 1649
5802 1215
2849 11681
15859 413
7453 3222
9492 5313
2309 13965
1361 8932
8017 5935
2256 7595
3056 8...

output:

17380 16599
16786 17261
17298 16897
16994 17312
16868 16381
17158 16535
17102 16894
16536 16455
17066 16495
16978 17187
17123 17352
17227 16865
16844 16866
17460 17248
16152 16959
16367 16189
16395 16819
17263 16960
16420 16171
17397 17409
16669 16880
16948 17463
16243 16254
16205 16872
16958 16385
...

result:

ok All OK (10 test cases)

Test #27:

score: 0
Accepted
time: 32ms
memory: 13564kb

input:

10
20000
7885 7071
16024 2454
788 1532
9107 5396
863 18365
13559 14595
5682 17596
10277 5565
5429 9775
9651 1543
10997 1585
15843 98
11709 18346
18893 357
19664 6276
4638 4202
11311 4463
13733 1689
19245 7795
4812 13596
11676 16057
16039 7395
9202 12081
19418 3855
10091 15515
9706 18698
16415 17647
...

output:

19188 19901
18778 19943
19780 19596
19700 19480
19288 19047
19697 19381
19296 19891
19246 19688
19749 19046
19023 19912
19789 19574
19478 19351
19190 19227
19895 18942
18902 19859
19215 19391
19425 18829
19602 19853
19232 19014
18951 19815
18748 18896
19041 19457
19251 18990
19051 18932
18832 19142
...

result:

ok All OK (10 test cases)

Test #28:

score: 0
Accepted
time: 36ms
memory: 14176kb

input:

10
20000
13043 670
237 4915
10906 409
19253 711
16317 876
742 15465
12586 690
796 16349
6763 627
868 3775
13797 715
13416 216
6989 798
136 8115
17811 451
18310 626
8943 534
376 1364
629 17957
719 5463
4847 46
3220 704
735 19173
17824 290
803 12001
9695 326
3717 696
156 16563
394 6627
3829 779
267 14...

output:

11984 12650
11149 19424
5809 3511
12358 14832
1734 7826
13707 7169
17586 6713
5631 15360
17003 16520
6862 9984
8969 9716
3049 9634
5239 10058
2312 14695
4121 10642
16610 5726
8321 5288
14966 6786
7201 6464
17739 10871
13839 10108
10924 14928
7497 9477
19269 13522
10909 8004
1895 12137
7980 11738
196...

result:

ok All OK (10 test cases)

Test #29:

score: 0
Accepted
time: 27ms
memory: 12796kb

input:

100
2000
1527 25
35 1691
1381 12
1214 51
67 1058
67 1122
195 75
883 16
316 30
13 645
75 577
34 604
1988 32
86 9
47 579
1453 38
97 431
727 83
1939 26
1533 97
68 1142
80 1675
39 1352
45 1302
96 154
49 1402
26 1388
1091 93
70 1804
97 1577
77 28
1667 20
5 1602
189 21
545 42
10 1495
13 337
30 6
1799 7
52...

output:

561 1698
1164 1974
361 395
1743 162
181 1008
1517 864
1459 1725
1877 336
1146 1650
146 150
1972 100
744 1409
483 462
1562 1864
1750 1211
1112 841
1361 1952
1136 1593
1526 1541
1827 918
1282 675
626 824
423 1753
1408 1513
406 1447
951 1565
1022 1131
108 987
1297 560
806 120
883 1221
263 736
927 559
4...

result:

ok All OK (100 test cases)

Test #30:

score: 0
Accepted
time: 30ms
memory: 12684kb

input:

100
2000
420 1219
945 1001
574 759
1646 1989
741 1939
54 210
1344 1645
832 1111
1685 1932
1581 612
1481 640
1634 928
971 924
136 1844
813 1516
860 331
103 1243
381 1348
839 849
423 1443
1766 1675
1462 513
961 1563
793 1687
378 279
1305 1510
818 966
668 1327
1133 1012
1356 1630
819 1261
70 521
1314 6...

output:

1995 1985
1992 1978
1988 2000
1997 1989
1979 1993
1982 1987
1991 1999
1996 1986
1981 1983
1980 1994
1990 1984
1998 1995
1940 1984
1949 1932
1927 1983
1987 1954
1933 1936
1923 1951
1922 1977
1930 1981
1926 1982
1931 1943
1929 1966
1974 1985
1994 1968
1963 1956
1992 1918
1938 1946
1969 1948
1944 1989
...

result:

ok All OK (100 test cases)

Test #31:

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

input:

1
200000
75527 3156
2623 154626
2558 177113
146357 1358
2656 186051
187792 523
4363 90605
100704 4773
87808 3697
502 173074
86283 3548
197007 2319
2809 174049
52610 666
1359 164293
25456 2472
4304 188852
4561 165894
180375 3811
5190 90244
199525 659
23244 4464
142850 282
690 124332
164450 5136
15018...

output:

174821 148902
27131 56077
98235 91099
144387 102042
43345 11991
23019 132640
127630 198859
59221 87988
94509 136979
188586 197148
134815 89020
193246 151282
30652 75765
48133 78827
146841 153727
10154 37724
143247 126674
71968 145839
34138 194885
156807 188309
173941 8966
95220 85226
80223 151988
16...

result:

ok All OK (1 test case)

Test #32:

score: 0
Accepted
time: 43ms
memory: 25904kb

input:

1
200000
83931 96937
32952 195907
78310 37108
176347 23132
188809 37384
140706 23700
17636 158568
5634 155262
58194 33410
47523 166455
128642 18909
178740 165831
85365 160502
187890 58358
25450 91847
140606 122655
63185 138517
189170 33052
136599 125275
91736 43965
108429 73952
40581 92844
147701 19...

output:

199993 199998
199989 199995
199996 199999
199988 200000
199992 199994
199991 199990
199997 199988

result:

ok All OK (1 test case)

Test #33:

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

input:

1
200000
193597 17230
27229 185684
159770 185467
10684 16681
197494 65016
145960 136670
147327 154108
79903 91787
146348 95359
23027 12513
23620 155067
337 181961
81189 147340
97553 64534
60153 114240
87847 125869
29991 186766
75418 153252
30768 107217
128834 162883
28777 29024
94836 138175
140266 1...

output:

199193 199232
199299 199448
199937 199994
199604 199409
199130 199900
199708 199666
199282 199713
199344 199102
199380 199425
199685 199718
199376 199142
199829 199763
199231 199969
199506 199350
199360 199479
199695 199281
199618 199596
199119 199848
199488 199820
199595 199207
199612 199337
199407...

result:

ok All OK (1 test case)