Logo Wy Online Judge

WyOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#634#116. 【0621 模拟赛】OBILAZAKWZL12121003ms3468kbC++14527b2025-06-21 15:11:582025-06-21 23:50:31

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,a[2020];
struct rode{
	int x,y;
};
queue<rode> q;
void bfs(){
	q.push(rode{1,(1<<n)-1});
	while(!q.empty()){
		int l=q.front().x,r=q.front().y;
		q.pop();
		cout<<a[(l+r)/2];
		if(r-l!=q.front().y-q.front().x) cout<<'\n';
		else cout<<' ';
		if(r-l+1!=1){
			q.push(rode{l,(l+r)/2-1});
			q.push(rode{(l+r)/2+1,r});
		}
	}
}
signed main(){
	cin>>n;
	for(int i=1;i<=(1<<n)-1;i++) cin>>a[i];
	bfs();
		
	
	return 0;
}//OBILAZAK

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3408kb

input:

10
441 314 935 337 172 628 445 670 715 953 761 525 432 951 217 785 577 933 855 275 178 664 198 298 4...

output:

404
602 213
147 737 965 842
42 730 351 430 494 493 490 141
248 974 681 618 505 196 207 805 255 600 1...

result:

ok 1023 tokens

Test #2:

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

input:

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

output:

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

result:

ok 15 tokens

Test #3:

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

input:

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

output:

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

result:

ok 31 tokens

Test #4:

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

input:

6
54 6 31 5 26 60 25 46 49 43 33 51 21 28 22 36 7 9 35 39 58 37 59 32 3 48 42 15 18 23 10 12 17 30 5...

output:

12
36 50
46 32 8 56
5 51 39 15 45 16 63 20
6 60 43 28 9 37 48 23 30 13 61 55 47 38 4 1
54 31 26 25 4...

result:

ok 63 tokens

Test #5:

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

input:

7
116 56 50 18 15 46 36 96 32 77 85 25 76 74 47 10 121 51 86 4 101 79 63 115 75 62 114 28 122 100 17...

output:

35
45 5
10 9 30 11
96 115 21 88 26 83 117 78
18 25 4 28 105 107 87 123 57 73 81 53 16 48 102 52
56 4...

result:

ok 127 tokens

Test #6:

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

input:

8
18 138 3 122 199 40 92 144 165 219 196 237 223 60 1 124 65 145 128 107 108 155 62 187 150 29 53 25...

output:

162
13 42
216 112 8 130
124 97 157 12 250 208 185 102
144 187 230 49 82 136 69 197 141 75 195 189 95...

result:

ok 255 tokens

Test #7:

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

input:

9
32 353 216 63 482 469 367 60 275 244 109 87 158 505 510 419 71 41 504 128 284 445 264 381 461 59 2...

output:

453
312 362
12 10 509 161
263 288 301 142 365 145 104 192
419 283 502 97 471 234 316 295 27 25 259 1...

result:

ok 511 tokens

Test #8:

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

input:

10
373 367 555 336 718 176 655 152 816 779 736 527 107 357 333 936 714 188 185 543 855 759 350 364 6...

output:

568
1010 1012
290 132 772 893
564 894 667 265 264 761 671 15
190 134 582 282 337 602 181 477 514 726...

result:

ok 1023 tokens

Test #9:

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

input:

10
400 58 680 758 18 699 340 5 192 936 916 362 142 236 383 801 12 753 622 205 428 486 499 341 979 95...

output:

559
883 116
51 320 195 732
277 687 866 653 128 174 652 317
76 466 85 171 855 455 542 696 415 523 995...

result:

ok 1023 tokens