QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#393885#1884. Mission Impossible: Grand Theft AutoHarry27182AC ✓37ms22352kbC++142.5kb2024-04-19 16:10:102024-04-19 16:10:10

Judging History

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

  • [2024-04-19 16:10:10]
  • 评测
  • 测评结果:AC
  • 用时:37ms
  • 内存:22352kb
  • [2024-04-19 16:10:10]
  • 提交

answer

#include<bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops,fast-math,no-stack-protector")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;
const int N=200005;
struct edge{int v,nxt;}e[N<<1];
int T,tp,id[N],deg[N],mx[N],mn[N],n,m,h[N],cnt,rt,ban[N],u,v;
void add(int u,int v){e[++cnt]={v,h[u]};h[u]=cnt;}
void dfs(int u,int fa)
{
	if(deg[u]==1)id[m]=u,mn[u]=mx[u]=m++;
	else mn[u]=0x3f3f3f3f,mx[u]=-0x3f3f3f3f;
	for(int i=h[u];i;i=e[i].nxt)
	{
		int v=e[i].v;
		if(v==fa)continue;
		dfs(v,u);
		mn[u]=min(mn[u],mn[v]);mx[u]=max(mx[u],mx[v]);
	}
}
namespace Sub0
{
	void main()
	{
		for(int i=1;i<=n;i++)
		{
			if(i==rt||deg[i]==2||(mx[i]-mn[i]+1)%2==1)continue;
			ban[(mn[i]+mx[i]+1)/2%(m/2)]++;
		}
		for(int x=0;x<m/2;x++)
		{
			if(ban[x]==0)
			{
				int a=x,b=(x-1+m)%m;
				for(int i=1;i<=m/2;i++)
				{
					cout<<id[a]<<' '<<id[b]<<'\n';
					a=(a+1)%m;b=(b-1+m)%m;
				}
				cout<<1<<' '<<1<<'\n';return;
			}
			else if(ban[x]==1)
			{
				int l=-1,r=-1;
				for(int i=1;i<=n;i++)
				{
					if(i==rt||deg[i]==2||(mx[i]-mn[i]+1)%2==1)continue;
					if((mn[i]+mx[i]+1)/2%(m/2)==x)l=mn[i],r=mx[i];
				}
				int A=r-l+1;int B=m-A,a=x,b=(x-1+m)%m;
				for(int i=1;i<=m/2;i++)
				{
					cout<<id[a]<<" "<<id[b]<<'\n';
					if(l<=a&&a<=r)A--;
					else B--;
					if(l<=b&&b<=r)A--;
					else B--;
					if(A==0||B==0)cout<<id[r]<<' '<<id[(r+1)%m]<<'\n',A=-1,B=-1;
					a=(a+1)%m;b=(b-1+m)%m;
				}
				if(A==0||B==0)cout<<id[r]<<' '<<id[(r+1)%m]<<'\n',A=-1,B=-1;
				return;
			}
		}
	}
}
namespace Sub1
{
	void main()
	{
		for(int i=1;i<=n;i++)
		{
			if(i==rt||deg[i]==2)continue;
			if((mx[i]-mn[i]+1)%2==0)ban[(mx[i]+mn[i]+1)/2%(m/2)]++;
			else ban[(mx[i]+mn[i]+1+m)/2%m]++;
		}
		for(int x=0;x<m;x++)
		{
			if(ban[x]==1)
			{
				int a=x,b=(x-1+m)%m;
				for(int i=1;i<=m/2;i++)
				{
					cout<<id[a]<<' '<<id[b]<<'\n';
					a=(a+1)%m;b=(b-1+m)%m;
				}
				cout<<id[(x+m/2)%m]<<' '<<id[(x+m/2+1)%m]<<'\n';
				return;
			}
		}
	}
}
int main()
{
    cin.tie(0)->sync_with_stdio(0);
    cin>>T;
    while(T--)
    {
    	cin>>n;
    	for(int i=0;i<=n;i++)deg[i]=h[i]=ban[i]=0;cnt=m=0;
    	for(int i=1;i<n;i++)
    	{
    		cin>>u>>v;
    		add(u,v);add(v,u);deg[u]++;deg[v]++;
		}
		int M=0;
		for(int i=1;i<=n;i++)M=max(M,deg[i]);
		if(n==2){cout<<"1 2\n1 2\n";continue;}rt=0;
		for(int i=1;i<=n;i++)if(deg[i]==M)rt=i;
		dfs(rt,0);
		if(m%2==0)Sub0::main();
		else Sub1::main();
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 9816kb

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

result:

ok All OK (4 test cases)

Test #2:

score: 0
Accepted
time: 24ms
memory: 9768kb

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:

445 1586
383 492
560 1234
1035 1224
1965 53
62 814
1886 72
1939 1604
1593 991
802 1255
758 298
1176 1407
1420 267
607 164
1982 851
1076 1572
1975 968
1031 1758
816 657
1021 1268
195 398
1678 457
561 515
1002 1401
1079 112
1293 1663
1196 1015
1350 1963
1835 1320
1136 1710
1174 1179
1012 971
568 1075
...

result:

ok All OK (100 test cases)

Test #3:

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

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:

837 1312
634 1706
1858 1913
1738 896
469 990
1968 892
1029 1592
1294 213
1602 332
1632 1430
410 145
199 901
1085 1269
928 564
215 843
1409 138
323 493
1214 1707
67 1368
1895 754
423 293
876 1095
1243 355
1456 341
1930 37
1740 1881
494 1455
75 605
90 1322
660 104
348 59
152 1699
682 1596
178 1501
166...

result:

ok All OK (100 test cases)

Test #4:

score: 0
Accepted
time: 24ms
memory: 7912kb

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
1 1
1059 401
1 1
289 1569
1 1
1845 1072
1 1
498 584
1 1
832 625
1 1
400 1656
1 1
252 631
1 1
1451 297
1 1
1379 540
1 1
920 1475
1 1
1598 1613
1 1
1645 853
1 1
908 137
1 1
1204 140
1 1
1460 454
1 1
1678 1496
1 1
755 143
1 1
164 15
1 1
1528 1099
1 1
1596 1985
1 1
1819 945
1 1
1708 17
1 1
561 1...

result:

ok All OK (100 test cases)

Test #5:

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

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:

1863 1055
1515 772
501 1922
1470 1637
1092 918
1115 1978
1472 929
356 520
511 495
1622 1320
1739 1169
1037 1483
526 186
1384 1795
1288 1238
1324 1335
1586 427
1560 503
1510 563
1429 1607
1460 952
1689 132
800 1673
1932 950
1437 1424
1792 1774
603 332
1940 734
24 1823
943 1917
318 1514
419 1865
1157 ...

result:

ok All OK (100 test cases)

Test #6:

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

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:

1206 1441
295 429
1280 218
615 1313
603 1004
970 862
1373 937
677 237
752 1113
1639 1310
471 1512
593 1182
1812 1348
1253 52
1964 1981
108 1130
1001 1706
258 264
69 1430
1746 641
1944 1750
3 1
190 1713
24 983
1074 1810
1242 1410
1384 1201
104 1765
16 452
663 400
1633 1211
1440 1462
1511 879
174 320
...

result:

ok All OK (100 test cases)

Test #7:

score: 0
Accepted
time: 22ms
memory: 9820kb

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:

1443 1812
1637 1720
1339 1703
1722 1744
1572 1593
1657 1827
1396 1984
1714 1180
1566 1945
1496 1413
1900 1964
1310 1495
1119 1519
1194 1736
1864 1873
1998 1621
1718 1822
1153 1968
1603 1914
1963 1630
1159 1825
1152 1230
1681 1212
1252 1606
1287 1368
1663 1903
1794 1512
1659 1454
1565 1709
1528 1468
...

result:

ok All OK (100 test cases)

Test #8:

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

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:

147917 28660
157584 186114
110481 66602
160803 28037
73595 197400
42587 66746
119197 61471
141619 163954
101167 21066
76770 129720
81566 171225
141560 2109
59994 44009
140824 178934
171547 169689
112874 27966
73364 22431
141742 34921
63437 61219
99115 168224
93351 77250
153810 186448
169905 144776
1...

result:

ok All OK (1 test case)

Test #9:

score: 0
Accepted
time: 33ms
memory: 11432kb

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:

177578 48337
133169 594
81895 41213
115145 118463
198366 132533
158108 108268
66423 62983
43674 18303
163407 132502
174722 59036
122364 19845
72359 194891
74205 84348
84148 65924
102600 62403
88974 47092
58699 55170
196776 46164
67640 185005
194668 96870
128394 119025
26022 52756
171126 147489
86934...

result:

ok All OK (1 test case)

Test #10:

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

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

result:

ok All OK (1 test case)

Test #11:

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

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:

132040 114579
1 1

result:

ok All OK (1 test case)

Test #12:

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

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:

49389 184634
67807 134574
88945 190853
40912 24343
3988 179098
91494 173609
42033 78768
119816 135709
66130 83577
133824 164997
31037 69953
175466 105548
187228 97427
120686 103651
126918 186628
20431 126725
128008 70579
46505 87095
37266 118502
171635 10394
86261 5261
44598 61563
89141 73054
37267 ...

result:

ok All OK (1 test case)

Test #13:

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

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:

85922 132796
88348 6985
62649 43750
159052 37257
139864 131692
133935 41449
94730 36733
199142 70721
194814 115034
199144 10557
164867 75420
192010 90374
138766 131268
136595 108671
132329 92063
149484 91048
34952 9299
48830 83604
41651 23343
166179 77655
32002 117964
173524 155365
97848 88851
17325...

result:

ok All OK (1 test case)

Test #14:

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

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:

121561 181709
182651 143876
102080 160916
147647 195303
115585 129790
105306 135393
183442 129458
176354 137330
194954 154490
141005 125505
130468 154132
110108 101663
177249 181162
110372 92832
150926 132802
105978 111289
175499 138785
155993 185871
170511 105710
141976 149655
140853 115125
161463 ...

result:

ok All OK (1 test case)

Test #15:

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

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:

6896 4298
10050 17314
19982 11993
11114 5765
12615 9119
4708 13951
9589 17169
14512 535
3667 5262
1676 1968
4732 2665
12030 4019
2364 12734
7099 5139
12375 1847
14619 5154
17062 13211
17507 4316
18603 370
12306 17922
13229 14044
5718 5875
9598 11219
12224 12616
7234 18346
10654 9107
1252 19467
12820...

result:

ok All OK (10 test cases)

Test #16:

score: 0
Accepted
time: 23ms
memory: 9824kb

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:

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

result:

ok All OK (10 test cases)

Test #17:

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

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:

12306 16131
5646 4175
5589 13389
9049 6845
7026 3484
12512 19666
10075 12751
19703 6327
19796 12830
18836 15463
7633 11314
3736 8057
8323 5839
18135 7480
10629 4839
4116 5680
17314 11259
15378 18871
16187 7573
3013 5065
4586 19
5191 3698
14762 17166
10561 16487
5151 17755
13230 15386
7243 18997
4309...

result:

ok All OK (10 test cases)

Test #18:

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

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:

6056 5715
6056 15668
15668 2847
10911 12902
9119 9022
12679 1277
12736 19833
14898 10635
11587 16177
7939 19995
5679 13024
16671 9381
4441 11117
10132 6991
7241 195
6758 17664
5212 6392
17049 10095
12911 5109
4452 18850
13408 3989
19165 15198
9396 14007
2526 13823
9241 7710
17651 12508
15527 9648
13...

result:

ok All OK (10 test cases)

Test #19:

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

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:

15490 19012
15331 17618
15529 16858
16887 16058
15861 19684
17877 16577
17749 15318
17337 18033
17403 15984
19935 18331
15271 19110
18215 15397
17311 16449
18435 17486
19874 15886
15826 15464
15805 17483
16274 15233
16978 19793
16957 19795
19661 16755
17254 15605
17431 19964
15988 15749
16905 19763
...

result:

ok All OK (10 test cases)

Test #20:

score: 0
Accepted
time: 17ms
memory: 9908kb

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:

7715 4857
1348 5869
224 6885
3694 6310
269 8564
1320 2586
6960 2481
9169 1852
10718 10454
5816 521
1443 1223
3316 5994
10995 854
3311 5932
9623 9165
809 4420
3195 8259
6966 7049
4606 11172
171 772
4602 10687
10210 4202
9766 4533
3582 9518
11204 8449
9108 8660
10160 8217
9030 3059
4730 9275
6880 1073...

result:

ok All OK (10 test cases)

Test #21:

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

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:

11721 12764
518 11640
8786 7077
3747 8750
2960 1686
328 7004
10744 10400
194 2947
3147 8854
3728 2229
686 3815
5748 8639
9437 12991
2208 10466
4491 4034
10501 1109
10604 9726
2476 8950
4648 11081
10114 1708
1365 9308
9494 11861
397 11308
1061 3419
5116 5967
85 3046
4638 2383
1140 4862
3153 2290
43 8...

result:

ok All OK (10 test cases)

Test #22:

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

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:

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

result:

ok All OK (10 test cases)

Test #23:

score: 0
Accepted
time: 23ms
memory: 8756kb

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:

5948 2080
9646 13945
6719 4873
13758 12678
14024 14000
12685 9848
7844 12202
13556 10089
13210 7821
1518 6968
5714 8553
810 2166
9368 2520
9269 3057
8702 2065
5080 7908
1513 4535
2620 9128
11115 2503
9424 3185
11069 13367
6256 6813
1125 5754
10612 1061
11631 6583
13119 7645
11137 8143
11317 4713
106...

result:

ok All OK (10 test cases)

Test #24:

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

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:

13122 12949
524 6113
13262 12968
3481 4571
14406 8522
2807 11990
11449 11459
5084 7795
13338 6371
2457 3818
3454 13772
7941 10208
8516 8448
176 14514
13560 8792
5901 12072
10730 10282
8588 1566
11071 6520
12908 12169
1881 8530
7834 8682
3535 8069
11862 6099
1421 2677
2486 5416
3423 12110
2164 11305
...

result:

ok All OK (10 test cases)

Test #25:

score: 0
Accepted
time: 11ms
memory: 8188kb

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:

13988 14260
13276 14447
14818 13204
12745 13342
13078 13972
13011 13322
13437 13145
13245 14627
13706 13952
14382 13451
13608 13549
13326 13010
13288 13262
13014 14782
14553 13577
13947 14253
14300 14817
13803 14786
13791 13264
13854 13538
13565 12790
13530 12736
13696 13135
12672 13317
13491 13934
...

result:

ok All OK (10 test cases)

Test #26:

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

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:

16532 16246
16298 17443
16409 17470
17181 17001
16930 17392
16477 17459
17302 16331
16729 16827
16341 17276
16350 16753
17306 17071
16756 16525
16312 16419
17198 17374
17121 16359
16739 16788
16867 16407
17157 17269
16899 16544
16247 17150
16573 16498
16343 17126
17190 16705
16351 17204
16584 17036
...

result:

ok All OK (10 test cases)

Test #27:

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

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:

19998 19204
19626 19314
18828 19580
19043 19760
19707 19932
18977 18888
19045 19910
19440 19137
19805 19849
19571 19087
19758 19670
19130 18826
18987 19250
19456 19093
19182 18907
19371 19743
18840 19117
18765 19791
18770 19325
19889 19184
19042 19327
19997 18891
18766 19274
19311 19575
19003 19028
...

result:

ok All OK (10 test cases)

Test #28:

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

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:

11579 1852
3605 10227
3346 9442
19729 6927
9323 4785
7405 18633
14639 15972
13865 18761
10417 7735
1923 13409
8405 7242
15797 15673
7386 1072
16096 2070
18823 18910
13309 2716
11681 12576
1947 13386
14900 16622
5471 7715
1129 16518
11333 14932
7790 9224
2290 16744
3175 4641
12741 5088
10415 11798
49...

result:

ok All OK (10 test cases)

Test #29:

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

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:

1677 154
848 228
1354 1027
1110 214
652 1537
890 985
1706 1232
364 1787
1973 1685
1387 1961
224 762
1374 201
664 1869
689 547
1037 672
1986 1496
1488 1959
428 1534
1876 1572
1912 579
496 1968
751 1225
202 502
984 1977
1815 1948
475 1632
1000 1448
1223 900
795 852
1996 1321
1383 223
621 1109
167 1343...

result:

ok All OK (100 test cases)

Test #30:

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

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:

1985 1990
1978 1998
2000 1999
1988 1987
1995 1994
1992 1983
1979 1986
1997 1984
1991 1993
1982 1980
1989 1996
1981 1996
1918 1926
1946 1989
1956 1948
1936 1939
1951 1916
1977 1929
1981 1974
1982 1994
1943 1963
1966 1992
1985 1938
1968 1969
1940 1944
1984 1957
1932 1928
1983 1934
1954 1995
1930 1964
...

result:

ok All OK (100 test cases)

Test #31:

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

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:

23261 182007
186183 89001
137092 96798
101553 116071
55846 26537
59235 161385
155105 133597
77943 192313
83143 161586
48883 147998
10607 123364
103990 66217
34189 138209
33262 102567
161421 133404
90455 142061
125020 95348
178991 189174
44541 188080
183566 101673
156681 64799
190045 131472
163650 65...

result:

ok All OK (1 test case)

Test #32:

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

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:

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

result:

ok All OK (1 test case)

Test #33:

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

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:

199444 199737
199148 199321
199441 199980
199901 199863
199226 199422
199743 199756
199518 199445
199726 199591
199280 199359
199744 199157
199294 199866
199405 199693
199492 199741
199687 199891
199288 199611
199903 199375
199681 199453
199705 199374
199834 199248
199346 199144
199392 199291
199752...

result:

ok All OK (1 test case)