QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#396641#4996. Icy ItineraryNetwork_ErrorTL 811ms77592kbC++141.7kb2024-04-22 22:39:552024-04-22 22:39:56

Judging History

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

  • [2024-04-22 22:39:56]
  • 评测
  • 测评结果:TL
  • 用时:811ms
  • 内存:77592kb
  • [2024-04-22 22:39:55]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define piii tuple<int,int,int>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define deb(var) cerr<<#var<<'='<<(var)<<"; "
int n,m,L[300010],R[300010];
map<int,map<int,bool> > p;
void sol2(){
	memset(L,0,sizeof L);
	memset(R,0,sizeof R);
	vector<int> vec(n);
	iota(vec.begin(),vec.end(),1);
	mt19937 rnd(time(0));
	shuffle(vec.begin(),vec.end(),rnd);
	int mid=1;
	for(auto i:vec){
		if(i==1)continue;
		if(!R[mid])L[R[mid]=i]=mid,mid=!p[mid][i]?i:mid;
//		else if(!L[mid])R[L[mid]=i]=mid,s=i;
		else{
			if(!p[mid][i]){
				int nxt=R[mid];
				L[R[mid]=i]=mid;
				R[L[nxt]=i]=nxt;
				mid=!p[i][nxt]?nxt:i;
			}else{
				int nxt=L[mid];
				if(!nxt)return;
				L[R[nxt]=i]=nxt;
				R[L[mid]=i]=mid;
				mid=!p[nxt][i]?i:nxt;
			}
		} 
	}
	for(int i=1;i;i=R[i])cout<<i<<' ';cout<<'\n';exit(0);
}
void sol1(){
	memset(L,0,sizeof L);
	memset(R,0,sizeof R);
	vector<int> vec(n);
	iota(vec.begin(),vec.end(),1);
	mt19937 rnd(time(0));
	shuffle(vec.begin(),vec.end(),rnd);
	int mid=1;
	for(auto i:vec){
		if(i==1)continue;
		if(!R[mid])L[R[mid]=i]=mid,mid=p[mid][i]?i:mid;
		else{
			if(p[mid][i]){
				int nxt=R[mid];
				L[R[mid]=i]=mid;
				R[L[nxt]=i]=nxt;
				mid=p[i][nxt]?nxt:i;
			}else{
				int nxt=L[mid];
				if(!nxt)return;
				L[R[nxt]=i]=nxt;
				R[L[mid]=i]=mid;
				mid=p[nxt][i]?i:nxt;
			}
		} 
	}
	for(int i=1;i;i=R[i])cout<<i<<' ';cout<<'\n';exit(0);
}
void work(){
	cin>>n>>m;
	for(int i=1,u,v;i<=m;i++)cin>>u>>v,p[u][v]=p[v][u]=1;
	while(1)sol1(),sol2();
}
signed main(){
	ios::sync_with_stdio(0),
	cin.tie(0),cout.tie(0);
	int T=1;while(T--)work();return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 4
1 2
1 3
1 4
3 4

output:

1 4 2 3 

result:

ok qwq

Test #2:

score: 0
Accepted
time: 0ms
memory: 6008kb

input:

5 0

output:

1 5 4 2 3 

result:

ok qwq

Test #3:

score: 0
Accepted
time: 2ms
memory: 6284kb

input:

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

output:

1 5 6 9 2 7 3 4 8 10 

result:

ok qwq

Test #4:

score: 0
Accepted
time: 2ms
memory: 6036kb

input:

2 1
1 2

output:

1 2 

result:

ok qwq

Test #5:

score: 0
Accepted
time: 1ms
memory: 5972kb

input:

2 0

output:

1 2 

result:

ok qwq

Test #6:

score: 0
Accepted
time: 1ms
memory: 6008kb

input:

3 1
1 3

output:

1 3 2 

result:

ok qwq

Test #7:

score: 0
Accepted
time: 0ms
memory: 6040kb

input:

10 40
10 9
4 5
2 7
3 4
4 7
4 9
7 3
5 10
5 9
8 1
1 10
6 7
6 9
9 8
10 7
7 8
8 3
10 3
2 1
1 5
6 1
5 7
2 5
3 9
2 8
1 9
4 1
1 7
4 10
2 10
3 1
4 6
9 7
3 6
2 3
8 4
6 8
3 5
4 2
2 6

output:

1 6 9 5 2 3 7 4 8 10 

result:

ok qwq

Test #8:

score: 0
Accepted
time: 1ms
memory: 6044kb

input:

10 45
7 2
6 3
7 10
5 1
1 9
6 8
10 1
2 10
10 8
10 5
6 2
4 3
6 7
10 3
3 2
1 8
10 9
2 5
9 2
4 1
8 3
8 2
5 7
4 8
9 4
1 7
7 3
6 10
4 2
6 4
10 4
3 1
8 5
4 7
1 6
9 5
3 9
6 5
5 4
9 7
2 1
8 9
3 5
6 9
7 8

output:

1 6 5 9 2 3 7 4 8 10 

result:

ok qwq

Test #9:

score: 0
Accepted
time: 0ms
memory: 5980kb

input:

15 40
12 11
11 6
5 11
15 14
10 14
15 5
1 11
10 12
4 3
6 4
4 9
2 11
6 12
13 7
7 9
10 9
1 2
9 11
2 6
7 14
2 9
3 13
9 1
2 7
8 11
1 10
13 1
4 15
3 7
2 15
6 5
10 15
4 14
15 6
2 4
3 11
1 14
2 8
1 8
10 7

output:

1 5 4 7 11 14 9 6 8 3 12 13 10 2 15 

result:

ok qwq

Test #10:

score: 0
Accepted
time: 2ms
memory: 6108kb

input:

15 1
13 6

output:

1 5 4 7 9 11 14 6 8 3 12 10 13 15 2 

result:

ok qwq

Test #11:

score: 0
Accepted
time: 0ms
memory: 6044kb

input:

150 150
110 99
80 122
55 67
24 47
73 68
150 13
94 140
146 59
136 28
94 134
131 2
26 105
65 79
57 37
116 102
84 16
110 78
72 5
34 8
8 43
83 57
49 146
43 112
54 139
95 13
11 95
75 29
29 30
52 14
118 56
4 51
18 146
31 113
56 69
44 14
63 123
44 66
101 122
52 10
16 118
71 93
22 113
28 88
5 108
16 48
84 1...

output:

1 62 105 101 103 44 48 138 104 73 66 24 137 132 28 72 102 18 106 74 20 39 14 45 109 144 25 115 7 71 99 31 108 94 118 46 98 88 59 52 89 107 136 38 51 17 19 83 140 111 50 32 15 13 90 116 75 110 81 16 95 145 67 121 47 6 117 36 127 34 79 119 86 76 37 49 123 53 64 3 122 131 126 35 63 30 26 58 82 78 80 9 ...

result:

ok qwq

Test #12:

score: 0
Accepted
time: 3ms
memory: 6664kb

input:

1500 1500
370 639
1046 375
1191 907
782 923
1369 196
998 194
640 331
309 631
1053 1076
887 1112
650 1437
2 1133
847 302
647 81
22 691
772 14
1112 62
266 1399
865 980
1302 1146
1007 575
1448 261
1489 1189
1134 1009
7 1175
1369 942
709 365
675 514
1021 1250
1415 2
976 746
564 388
431 326
43 147
385 81...

output:

1 1313 1266 1191 939 1347 339 138 1417 558 376 242 731 290 914 1058 230 1200 1145 595 1263 1310 1130 766 732 1495 25 1258 1201 1397 309 1171 316 1138 838 811 665 933 1197 52 895 561 153 1418 846 391 805 83 1367 182 648 1311 1462 493 1472 540 75 1302 865 209 897 1270 357 412 618 735 295 36 685 984 14...

result:

ok qwq

Test #13:

score: 0
Accepted
time: 15ms
memory: 9864kb

input:

15000 15000
11602 9990
5492 14226
2633 14599
7956 12544
1258 1198
13788 3283
171 3770
8226 10782
915 6735
7186 14219
12806 1549
8783 5596
3692 9668
370 4654
13811 4032
835 12990
14273 14020
8902 7798
7405 4524
7476 1864
7786 14984
4367 13552
2927 2463
1929 3198
97 5800
14012 5674
6283 827
13860 1139...

output:

1 9902 4103 12817 14166 10519 7868 11928 14303 5652 11953 13551 14591 6817 9316 1058 14423 1200 6179 11109 7578 6829 6377 7332 11300 11878 4595 12657 3096 7532 3206 14866 10579 14162 6317 6048 5721 3745 1627 11545 14025 561 7350 8954 4221 5455 805 14433 8866 2380 648 6062 11899 12880 3357 5121 12597...

result:

ok qwq

Test #14:

score: 0
Accepted
time: 179ms
memory: 49332kb

input:

300000 0

output:

1 224983 99136 216248 131734 256246 86019 220296 113231 215654 138439 157349 10388 161627 106469 144810 121931 12020 84867 69295 57655 254614 55864 256706 8494 29821 130777 28696 208270 200609 82001 67241 13773 173055 42267 88963 87150 262494 266739 154755 239456 263224 41859 278450 194492 184350 17...

result:

ok qwq

Test #15:

score: 0
Accepted
time: 213ms
memory: 49628kb

input:

300000 1
80856 110687

output:

1 224983 99136 216248 131734 256246 86019 220296 113231 215654 138439 157349 10388 161627 106469 144810 121931 12020 84867 69295 57655 254614 55864 256706 8494 29821 130777 28696 208270 200609 82001 67241 13773 173055 42267 88963 87150 262494 266739 154755 239456 263224 41859 278450 194492 184350 17...

result:

ok qwq

Test #16:

score: 0
Accepted
time: 235ms
memory: 49404kb

input:

300000 100
254473 70041
278954 218026
54339 23948
90766 35432
145294 42945
10824 168971
162204 196321
137959 274421
274330 8901
113606 229638
136217 161945
232685 214848
91296 146678
8764 206628
297190 163150
140047 161791
188167 261504
261443 160497
262029 233857
112139 37654
43010 192683
3697 1727...

output:

1 224983 99136 216248 131734 256246 86019 220296 113231 215654 138439 157349 10388 161627 106469 144810 121931 12020 84867 69295 57655 254614 55864 256706 8494 29821 130777 28696 208270 200609 82001 67241 13773 173055 42267 88963 87150 262494 266739 154755 239456 263224 41859 278450 194492 184350 17...

result:

ok qwq

Test #17:

score: 0
Accepted
time: 349ms
memory: 58772kb

input:

300000 100000
279619 105099
95580 46691
139476 105331
67098 144910
105689 84242
198438 147050
274697 179922
229381 179041
210820 243557
162433 137909
14644 17464
295783 151723
180167 63360
17314 119555
201506 121519
129982 11913
3312 283798
197026 175391
86210 36036
177182 150502
37900 95301
261630 ...

output:

1 114747 164603 280245 147609 127434 294303 163155 48647 234623 204862 118540 203092 53069 23242 38722 204889 5508 83375 224910 80525 106144 27926 17078 64931 295779 283839 38572 72729 124130 174677 50435 145557 142446 175095 88971 94613 52873 247526 39946 88373 245960 155242 46687 291744 171688 116...

result:

ok qwq

Test #18:

score: 0
Accepted
time: 811ms
memory: 77592kb

input:

300000 300000
297121 280398
49505 181149
186167 88552
250816 195719
113345 180891
103968 274040
148345 167433
283785 32444
281156 62491
76167 222701
181130 69399
291957 220950
21996 17907
98113 270806
247895 36687
122761 248769
235623 41248
274601 174896
296046 235115
57460 64170
286130 15089
91951 ...

output:

1 290076 25106 121244 97179 174000 282396 211796 193633 226310 148042 45681 94622 59852 184394 280664 274337 262955 261657 159380 219315 178146 81984 154398 256023 121425 193893 171838 284638 69568 32347 145654 75473 176587 118874 193572 239265 206492 160887 233002 37657 226540 251691 55156 114340 2...

result:

ok qwq

Test #19:

score: 0
Accepted
time: 387ms
memory: 34268kb

input:

1000 300000
794 378
253 365
792 287
235 482
50 807
795 174
786 980
763 645
615 440
364 542
209 856
925 709
965 709
755 592
242 870
960 978
253 404
164 439
931 998
443 318
663 958
560 445
970 245
192 631
321 621
120 472
402 520
939 454
436 893
840 577
112 961
509 9
815 190
357 128
52 433
554 967
384 ...

output:

1 312 271 787 461 440 284 313 539 516 858 806 304 252 70 292 389 861 487 902 579 122 1000 92 219 489 947 968 762 430 277 135 382 551 508 852 887 263 860 437 716 767 490 446 597 541 4 709 468 671 760 62 504 19 376 702 613 624 733 444 457 179 829 274 3 308 604 276 366 358 156 459 417 655 492 442 447 7...

result:

ok qwq

Test #20:

score: 0
Accepted
time: 368ms
memory: 34656kb

input:

1500 300000
1189 1031
85 1047
1096 1290
1497 193
885 27
603 979
1438 1441
507 1256
1432 803
332 750
536 157
333 1248
1009 943
857 422
849 796
1399 814
911 481
836 36
1360 1175
592 737
277 672
551 331
849 1049
725 343
1312 112
889 544
1154 691
1387 1326
91 481
432 689
1051 248
1069 1499
499 194
748 1...

output:

1 271 1108 410 721 312 1334 461 1009 313 284 539 516 1226 806 304 532 252 292 70 487 861 1000 1068 277 122 1210 219 1012 489 1429 968 389 430 762 1213 33 1131 822 551 1058 508 852 641 437 263 887 1017 446 1295 1471 366 702 490 1353 1274 1011 709 1265 4 597 468 1401 504 1279 733 829 624 457 613 3 604...

result:

ok qwq

Test #21:

score: 0
Accepted
time: 362ms
memory: 35844kb

input:

10000 300000
1236 4556
6003 6937
2217 6717
1150 1520
835 87
6994 6123
4263 8371
6772 4802
7302 3130
6157 4469
9918 3820
1997 5129
9662 7860
5882 9655
4931 8546
4776 1017
3925 6960
8114 6760
7793 3511
2958 3481
7244 3603
8609 4155
1832 2597
1639 6861
6563 8641
7870 3706
3772 4396
7696 6907
8722 1019
...

output:

1 1172 7064 4475 6267 5965 1855 6793 4891 5303 9517 6608 3863 4621 3305 3426 1563 4939 2211 4558 6481 257 6325 7922 5143 2882 343 8775 3096 4764 5737 7650 9449 3199 3105 7955 6708 1289 5464 2284 4105 1743 6451 5749 1681 3329 9749 1704 3344 7378 2611 7527 5003 227 6213 9727 1010 1099 8088 9184 6826 8...

result:

ok qwq

Test #22:

score: 0
Accepted
time: 1ms
memory: 6076kb

input:

10 40
1 5
2 5
3 5
4 5
6 5
7 5
8 5
9 5
10 5
1 2
3 2
4 2
6 2
7 2
8 2
9 2
10 2
1 4
3 4
6 4
7 4
8 4
9 4
10 4
1 10
3 10
6 10
7 10
8 10
9 10
1 3
6 3
7 3
8 3
9 3
1 8
6 8
7 8
9 8
1 9

output:

1 8 10 9 3 2 7 5 6 4 

result:

ok qwq

Test #23:

score: 0
Accepted
time: 2ms
memory: 6296kb

input:

100 198
1 7
2 7
3 7
4 7
5 7
6 7
8 7
9 7
10 7
11 7
12 7
13 7
14 7
15 7
16 7
17 7
18 7
19 7
20 7
21 7
22 7
23 7
24 7
25 7
26 7
27 7
28 7
29 7
30 7
31 7
32 7
33 7
34 7
35 7
36 7
37 7
38 7
39 7
40 7
41 7
42 7
43 7
44 7
45 7
46 7
47 7
48 7
49 7
50 7
51 7
52 7
53 7
54 7
55 7
56 7
57 7
58 7
59 7
60 7
61 7
...

output:

1 81 65 43 22 89 84 32 44 39 4 85 28 2 48 90 13 51 36 46 83 11 42 3 37 53 74 10 97 63 5 64 92 49 61 77 98 18 88 79 45 31 12 9 20 58 26 54 86 56 66 60 8 29 78 73 87 82 93 96 41 6 21 95 40 55 67 47 23 75 35 17 76 94 62 70 16 24 68 38 25 69 91 71 15 34 100 80 57 19 30 99 33 50 59 27 52 72 14 7 

result:

ok qwq

Test #24:

score: 0
Accepted
time: 112ms
memory: 34244kb

input:

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

output:

1 821 869 602 201 277 103 982 633 618 503 810 874 245 358 42 842 131 265 123 5 955 304 545 818 456 764 171 629 26 484 541 485 903 910 355 144 87 96 73 984 154 40 294 253 656 410 47 361 721 158 472 587 475 226 120 99 642 346 791 981 354 544 802 424 563 325 172 247 679 175 888 12 39 630 473 553 616 94...

result:

ok qwq

Test #25:

score: 0
Accepted
time: 117ms
memory: 34828kb

input:

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

output:

1 821 1631 2788 1848 1951 223 1519 1483 982 1065 2605 2640 2589 1634 1934 692 768 778 1706 245 358 1010 2756 2332 438 1373 1702 131 2647 2479 2426 1143 359 61 663 1164 1526 2744 2895 1012 764 1193 413 1562 1176 2111 1630 484 1721 541 1095 60 903 1860 847 78 1626 2651 1205 1803 1320 1467 2842 2667 29...

result:

ok qwq

Test #26:

score: 0
Accepted
time: 123ms
memory: 35600kb

input:

10000 300000
1 9020
2 9020
3 9020
4 9020
5 9020
6 9020
7 9020
8 9020
9 9020
10 9020
11 9020
12 9020
13 9020
14 9020
15 9020
16 9020
17 9020
18 9020
19 9020
20 9020
21 9020
22 9020
23 9020
24 9020
25 9020
26 9020
27 9020
28 9020
29 9020
30 9020
31 9020
32 9020
33 9020
34 9020
35 9020
36 9020
37 9020
...

output:

1 821 7632 9220 4921 9022 223 9667 6394 5692 4683 2605 9665 6916 9462 7655 692 7441 778 1706 3978 5365 1010 2756 4447 4605 9752 5606 4268 2647 6205 2426 7548 8172 61 5844 1164 5639 7528 2895 1012 6601 8938 8804 4719 1176 4518 9294 7788 8688 541 1095 9717 903 1860 847 7422 9633 4597 1205 8521 9656 51...

result:

ok qwq

Test #27:

score: 0
Accepted
time: 177ms
memory: 39948kb

input:

40000 300000
1 8681
2 8681
3 8681
4 8681
5 8681
6 8681
7 8681
8 8681
9 8681
10 8681
11 8681
12 8681
13 8681
14 8681
15 8681
16 8681
17 8681
18 8681
19 8681
20 8681
21 8681
22 8681
23 8681
24 8681
25 8681
26 8681
27 8681
28 8681
29 8681
30 8681
31 8681
32 8681
33 8681
34 8681
35 8681
36 8681
37 8681
...

output:

1 20507 29739 36262 14115 21903 36712 17913 13051 26616 23995 10787 19243 18444 38684 3580 3707 13908 3285 4004 14891 1258 26567 35776 8267 3143 24077 2868 2624 4986 20788 1597 33116 24713 32205 5134 23036 34976 29597 19186 31314 34705 31596 15462 26509 19796 2535 20452 32791 2575 32636 7570 10507 2...

result:

ok qwq

Test #28:

score: 0
Accepted
time: 252ms
memory: 48656kb

input:

100000 300000
1 97406
2 97406
3 97406
4 97406
5 97406
6 97406
7 97406
8 97406
9 97406
10 97406
11 97406
12 97406
13 97406
14 97406
15 97406
16 97406
17 97406
18 97406
19 97406
20 97406
21 97406
22 97406
23 97406
24 97406
25 97406
26 97406
27 97406
28 97406
29 97406
30 97406
31 97406
32 97406
33 9740...

output:

1 15461 89460 23482 9085 9147 92054 91940 77747 53453 81737 7527 13712 28229 49269 43512 99330 47191 23251 74366 15371 519 62945 13682 5924 43060 68806 91212 94265 3031 65944 53777 31179 66161 39465 74528 38486 29150 97203 73243 61975 52005 46461 66434 2167 17699 86341 3642 99371 84363 38462 60269 2...

result:

ok qwq

Test #29:

score: 0
Accepted
time: 488ms
memory: 77528kb

input:

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

output:

1 91507 158266 18624 266605 273246 272545 25988 187282 220692 102065 292226 86535 142299 115968 135900 153204 152665 227503 208914 126940 141373 43053 80850 236971 203971 231512 238573 212709 138960 59299 175449 60746 278579 146395 75987 226416 231027 144255 12778 104594 182224 121062 232591 294315 ...

result:

ok qwq

Test #30:

score: 0
Accepted
time: 208ms
memory: 29548kb

input:

1000 249500
1 702
1 559
1 154
1 284
1 707
1 397
1 281
1 105
1 856
1 712
1 864
1 638
1 640
1 984
1 134
1 819
1 36
1 820
1 146
1 779
1 516
1 420
1 721
1 932
1 426
1 922
1 790
1 167
1 365
1 667
1 690
1 357
1 543
1 778
1 473
1 9
1 239
1 746
1 983
1 141
1 349
1 852
1 826
1 553
1 929
1 628
1 500
1 352
1 6...

output:

1 72 50 523 507 412 47 660 281 977 664 848 966 533 172 714 965 657 733 89 759 748 588 841 927 642 539 889 998 900 80 214 731 879 614 402 32 797 938 688 39 432 41 536 148 785 292 461 792 708 204 930 42 999 553 8 632 527 529 793 989 847 105 96 902 818 943 15 983 315 805 452 599 946 57 925 83 211 906 2...

result:

ok qwq

Test #31:

score: 0
Accepted
time: 113ms
memory: 29196kb

input:

750 245875
1 596
1 476
1 375
1 129
1 650
1 604
1 579
1 302
1 574
1 322
1 351
1 206
1 107
1 535
1 597
1 135
1 516
1 330
1 515
1 151
1 357
1 146
1 4
1 150
1 85
1 15
1 655
1 227
1 549
1 311
1 560
1 705
1 273
1 249
1 307
1 191
1 398
1 691
1 621
1 257
1 268
1 729
1 593
1 61
1 139
1 630
1 172
1 740
1 306
...

output:

1 603 579 533 172 714 227 379 273 585 15 287 357 662 85 595 139 591 549 488 129 97 597 570 351 534 621 355 150 734 574 188 476 430 330 431 206 415 4 509 61 213 655 52 593 702 268 405 322 445 535 87 191 711 705 197 135 264 151 511 515 233 560 40 307 406 596 459 146 495 375 710 516 194 630 11 302 274 ...

result:

ok qwq

Test #32:

score: 0
Accepted
time: 109ms
memory: 29132kb

input:

750 245875
1 368
1 278
1 71
1 353
1 405
1 149
1 616
1 153
1 622
1 655
1 105
1 682
1 140
1 668
1 352
1 210
1 257
1 677
1 749
1 612
1 234
1 35
1 400
1 604
1 193
1 505
1 230
1 586
1 358
1 737
1 428
1 346
1 279
1 395
1 584
1 691
1 73
1 435
1 639
1 205
1 320
1 496
1 384
1 295
1 522
1 672
1 309
1 250
1 43...

output:

1 507 47 50 523 412 657 89 660 281 122 664 603 579 533 172 714 227 733 678 10 217 748 588 340 428 273 350 642 539 491 563 57 731 506 614 402 599 41 32 450 39 432 536 381 148 67 292 461 490 708 644 187 204 440 105 421 42 234 529 632 553 8 527 695 182 96 585 15 435 315 452 285 496 633 83 211 253 462 6...

result:

ok qwq

Test #33:

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

input:

750 101324
1 411
1 270
1 170
1 697
1 76
1 64
1 744
1 353
1 109
1 115
1 133
1 560
1 453
1 690
1 297
1 733
1 523
1 479
1 62
1 32
1 80
1 578
1 261
1 682
1 506
1 303
1 646
1 229
1 750
1 421
1 322
1 168
1 543
1 568
1 456
1 138
1 57
1 380
1 534
1 131
1 452
1 614
1 174
1 207
1 617
1 123
1 562
1 69
1 567
1 ...

output:

1 507 72 47 523 657 89 50 660 412 281 122 664 603 172 714 579 227 533 733 678 10 217 748 588 340 428 417 273 563 57 403 80 731 506 214 614 566 402 41 32 599 450 491 39 539 2 642 688 461 490 292 708 644 187 67 204 148 440 381 105 536 421 42 234 527 695 182 96 15 435 585 315 8 452 553 285 496 633 462 ...

result:

ok qwq

Test #34:

score: 0
Accepted
time: 222ms
memory: 10412kb

input:

750 45299
1 415
1 743
1 571
1 531
1 419
1 378
1 188
1 454
1 117
1 344
1 362
1 180
1 461
1 228
1 693
1 115
1 275
1 250
1 501
1 618
1 322
1 217
1 42
1 398
1 129
1 88
1 414
1 740
1 90
1 528
1 437
1 124
1 733
1 241
1 487
1 72
1 295
1 366
1 748
1 143
1 55
1 113
1 534
1 479
1 555
1 712
1 349
1 586
1 212
1...

output:

1 21 96 204 205 207 277 449 147 505 367 660 515 556 420 210 351 588 659 368 263 491 86 577 44 129 689 182 457 499 26 552 677 133 533 101 537 535 480 373 606 468 131 253 40 57 728 437 597 298 193 109 334 229 269 115 70 507 60 219 444 748 329 573 695 487 280 465 332 542 116 94 631 650 518 433 438 159 ...

result:

ok qwq

Test #35:

score: 0
Accepted
time: 121ms
memory: 30416kb

input:

750 258869
1 124
1 233
1 740
1 493
1 145
1 749
1 142
1 224
1 308
1 572
1 33
1 660
1 246
1 377
1 690
1 105
1 741
1 692
1 497
1 334
1 481
1 450
1 366
1 307
1 739
1 165
1 730
1 430
1 332
52 349
52 424
52 212
52 555
52 531
52 426
52 379
52 637
52 635
52 434
52 40
52 404
52 261
52 190
52 557
52 225
52 52...

output:

1 367 660 193 334 465 332 279 124 3 105 524 740 608 739 37 430 38 224 391 33 357 497 713 307 252 572 471 690 625 142 570 246 30 366 132 165 474 730 711 145 503 308 29 749 356 450 715 377 387 481 345 493 727 692 731 233 545 741 83 591 14 627 668 55 647 452 475 716 293 720 84 257 17 454 161 254 388 23...

result:

ok qwq

Test #36:

score: 0
Accepted
time: 2ms
memory: 6324kb

input:

750 1154
1 433
1 99
1 563
1 370
1 149
1 218
1 477
1 170
1 98
1 299
1 586
1 574
1 51
1 667
1 539
1 659
1 615
1 730
1 12
1 694
1 695
1 662
1 166
1 253
1 84
1 420
1 533
1 231
1 410
433 99
433 563
433 370
433 149
433 218
433 477
433 170
433 98
433 299
433 586
433 574
433 51
433 667
433 539
433 659
433 6...

output:

1 21 96 204 205 207 277 449 147 505 367 660 515 556 420 210 351 588 659 368 263 491 86 577 419 44 401 129 689 535 552 499 182 457 26 677 133 533 101 537 480 229 468 373 606 131 57 253 40 728 109 437 597 298 193 334 269 115 70 487 507 60 573 748 219 444 329 695 280 175 750 212 542 465 332 116 650 94 ...

result:

ok qwq

Test #37:

score: -100
Time Limit Exceeded

input:

750 1924
1 211
1 576
1 697
1 175
1 675
1 641
1 301
1 227
1 311
1 669
1 637
1 673
1 245
1 548
1 74
1 740
1 134
1 561
1 90
1 185
1 511
1 57
1 478
1 423
1 310
1 741
1 550
1 7
1 712
1 725
1 293
1 361
1 593
1 558
1 414
1 356
1 94
1 120
1 700
1 60
1 434
1 226
1 647
1 453
1 328
1 221
1 28
1 352
1 11
1 654
...

output:


result: