#include <bits/stdc++.h>
using namespace std;
int log_2(int n) {
int p = 0;
while (n > 1) {
n /= 2;
++p;
}
return p;
}
int main()
{
int n;
cin >> n;
vector < int > a(1 << n);
vector < int > b(1 << n);
for (int i = 0; i < (1 << n); ++i) {
cin >> a[i];
b[i] = a[i];
}
map < int, int > m;
sort(a.begin(), a.end());
for (int i = 0; i + 1 < (1 << n); ++i) {
if (a[i + 1] > a[i]) {
m[a[i]] = int(log_2(i + 1));
}
}
m[a[(1 << n) - 1]] = n;
for (int i : b) {
cout << n - m[i] << " ";
}
cout << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
600 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
14 ms |
1116 KB |
Output is correct |
6 |
Correct |
37 ms |
2932 KB |
Output is correct |
7 |
Correct |
73 ms |
4180 KB |
Output is correct |
8 |
Correct |
102 ms |
3408 KB |
Output is correct |
9 |
Correct |
422 ms |
20612 KB |
Output is correct |
10 |
Correct |
908 ms |
31444 KB |
Output is correct |