QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#396635#4996. Icy ItineraryNetwork_ErrorWA 554ms97056kbC++141.7kb2024-04-22 22:36:442024-04-22 22:36:45

Judging History

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

  • [2024-04-22 22:36:45]
  • 评测
  • 测评结果:WA
  • 用时:554ms
  • 内存:97056kb
  • [2024-04-22 22:36:44]
  • 提交

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)<<"; "
#define int long long
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{
//			deb(i);
			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];
				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';
}
void work(){
	cin>>n>>m;
	for(int i=1,u,v;i<=m;i++)cin>>u>>v,p[u][v]=p[v][u]=1;
	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{
//			deb(i);
			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){
					sol2();exit(0);
				}
				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';
}
signed main(){
	ios::sync_with_stdio(0),
	cin.tie(0),cout.tie(0);
	int T=1;while(T--)work();return 0;
}

详细

Test #1:

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

input:

4 4
1 2
1 3
1 4
3 4

output:

1 4 3 2 

result:

ok qwq

Test #2:

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

input:

5 0

output:

1 2 4 5 3 

result:

ok qwq

Test #3:

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

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 3 10 6 9 7 2 4 8 

result:

ok qwq

Test #4:

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

input:

2 1
1 2

output:

1 2 

result:

ok qwq

Test #5:

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

input:

2 0

output:

1 2 

result:

ok qwq

Test #6:

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

input:

3 1
1 3

output:

1 3 2 

result:

ok qwq

Test #7:

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

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 5 3 10 9 6 7 2 4 8 

result:

ok qwq

Test #8:

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

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 5 3 10 6 9 7 2 4 8 

result:

ok qwq

Test #9:

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

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 14 7 2 15 11 4 12 8 10 3 9 5 13 6 

result:

ok qwq

Test #10:

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

input:

15 1
13 6

output:

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

result:

ok qwq

Test #11:

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

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 46 148 122 12 100 26 129 119 45 102 124 121 75 61 32 132 41 70 40 126 134 90 20 60 143 116 144 83 55 140 22 64 89 25 77 91 142 50 146 135 84 23 67 10 88 87 79 80 82 103 19 47 111 30 4 104 145 57 94 96 123 118 138 81 43 15 2 120 6 68 5 85 72 106 114 29 37 101 21 117 36 71 14 93 54 109 115 133 65 56...

result:

ok qwq

Test #12:

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

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 940 631 1457 1268 785 1482 135 442 172 1087 625 41 1012 777 122 669 72 806 277 899 929 1421 602 852 981 194 183 492 802 1361 54 89 710 784 1419 346 1498 843 1083 354 1236 1212 21 933 191 449 1261 328 432 594 621 102 1329 289 774 222 889 134 1051 69 71 937 503 364 591 1090 309 263 2 350 1134 16 244...

result:

ok qwq

Test #13:

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

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 5122 2663 4884 7315 12861 4043 135 7566 4678 7517 14149 3226 9572 10363 3705 12872 2636 806 9785 11670 8769 8121 602 13029 13021 1504 10414 5493 1699 4699 11679 89 7704 14172 12018 12476 9325 10825 2143 3666 8397 8563 8408 7024 1557 12518 4916 7912 8049 9929 11667 7675 11864 12046 10000 7276 1534 ...

result:

ok qwq

Test #14:

score: 0
Accepted
time: 168ms
memory: 59632kb

input:

300000 0

output:

1 283063 223859 261614 269434 82487 252883 236352 197981 149680 133770 49514 92672 249742 127037 103109 243888 113185 128364 272630 185304 32594 109042 277177 27613 100281 113634 153056 62892 167067 246688 49584 220843 62676 82374 74979 276484 224995 29359 13877 118457 150301 177655 84402 52796 8678...

result:

ok qwq

Test #15:

score: 0
Accepted
time: 169ms
memory: 59568kb

input:

300000 1
80856 110687

output:

1 283063 223859 261614 269434 82487 252883 236352 197981 149680 133770 49514 92672 249742 127037 103109 243888 113185 128364 272630 185304 32594 109042 277177 27613 100281 113634 153056 62892 167067 246688 49584 220843 62676 82374 74979 276484 224995 29359 13877 118457 150301 177655 84402 52796 8678...

result:

ok qwq

Test #16:

score: 0
Accepted
time: 175ms
memory: 59712kb

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 283063 223859 261614 269434 82487 252883 236352 197981 149680 133770 49514 92672 249742 127037 103109 243888 113185 128364 272630 185304 32594 109042 277177 27613 100281 113634 153056 62892 167067 246688 49584 220843 62676 82374 74979 276484 224995 29359 13877 118457 150301 177655 84402 52796 8678...

result:

ok qwq

Test #17:

score: 0
Accepted
time: 281ms
memory: 72096kb

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 15752 170645 79130 71504 159824 57435 39324 83893 50349 20496 172903 129234 256354 257842 284544 61664 22418 204396 290873 52577 133659 33956 237545 155131 138205 200503 135887 120041 129060 26376 217292 237413 149990 149705 215637 62365 83612 139639 252877 272505 198013 190631 68874 278606 277358...

result:

ok qwq

Test #18:

score: 0
Accepted
time: 554ms
memory: 97056kb

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 15752 170645 79130 71504 159824 57435 39324 83893 50349 20496 172903 129234 256354 257842 284544 61664 22418 204396 290873 52577 133659 33956 237545 155131 138205 200503 135887 120041 129060 26376 217292 237413 149990 149705 215637 62365 83612 139639 252877 272505 198013 190631 68874 278606 277358...

result:

ok qwq

Test #19:

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

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 29 345 110 887 84 469 15 418 524 439 56 214 429 387 910 409 482 744 128 14 870 41 890 255 822 704 442 699 672 839 206 597 80 127 700 443 152 452 938 79 687 962 645 371 245 403 53 896 96 40 878 36 217 186 519 393 927 533 595 770 760 553 94 769 897 592 964 7 415 447 505 262 830 512 489 752 402 506 4...

result:

ok qwq

Test #20:

score: -100
Wrong Answer
time: 267ms
memory: 46192kb

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 487 299 1047 1493 727 24 1073 669 86 942 545 971 1475 710 31 593 1478 1126 967 897 1043 842 324 2 824 834 895 806 888 1349 1018 523 514 483 208 908 1070 1242 339 21 1180 564 1292 227 901 1391 394 697 947 917 474 550 259 84 1207 432 640 910 1157 1074 1363 1400 407 654 624 466 356 1460 491 973 825 5...

result:

wrong output format Unexpected end of file - int32 expected