ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#685 | #116. 【0621 模拟赛】OBILAZAK | wfirstzhang | 100 | 8ms | 3412kb | C++14 | 866b | 2025-06-21 15:59:35 | 2025-06-21 23:52:20 |
answer
#include <algorithm>
#include <iostream>
#include <vector>
void search(unsigned node, int& id, int layer, int n, int* node_id, auto& map);
int main() {
using namespace std;
int n;
cin >> n;
auto arr = new int[1 << n];
for(int i = 0; i < (1 << n) - 1; i++)
cin >> arr[i];
auto map = new int[1 << n];
int id = -1;
search(1, id, 0, n, arr, map);
id = 0;
for(int i = 0; i < n; i++)
{
for(int j = 0; j < (1 << i); j++)
cout << map[id++] << ' ';
cout << endl;
}
delete[] map;
delete[] arr;
return 0;
}
void search(unsigned node, int& id, int layer, int n, int* node_id, auto& map) {
if(layer == n - 1)
{
++id;
map[node - 1] = node_id[id];
return;
}
search(node << 1, id, layer + 1, n, node_id, map);
++id;
map[node - 1] = node_id[id];
search(node << 1 | 1, id, layer + 1, n, node_id, map);
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3328kb
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 6...
result:
ok 1023 tokens
Test #2:
score: 0
Accepted
time: 0ms
memory: 3300kb
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: 3376kb
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: 3412kb
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...
result:
ok 63 tokens
Test #5:
score: 0
Accepted
time: 0ms
memory: 3296kb
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 ...
result:
ok 127 tokens
Test #6:
score: 0
Accepted
time: 1ms
memory: 3292kb
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 18...
result:
ok 255 tokens
Test #7:
score: 0
Accepted
time: 2ms
memory: 3300kb
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 2...
result:
ok 511 tokens
Test #8:
score: 0
Accepted
time: 1ms
memory: 3224kb
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...
result:
ok 1023 tokens
Test #9:
score: 0
Accepted
time: 1ms
memory: 3328kb
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...
result:
ok 1023 tokens