#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
int n;
cin >> n;
vector<int> b(1 << n);
vector<pair<int, int>> a(1 << n);
for(int i = 0; i < (1 << n); i ++){
cin >> a[i].first;
a[i].second = i;
b[i] = a[i].first;
}
sort(a.begin(), a.end());
map<int, int> res;
for(int i = 0; i < (1 << n); i ++){
res[a[i].first] = max(res[a[i].first], int(floor(log2(i + 1))));
}
for(int i = 0; i < (1 << n); i ++){
cout << n - res[b[i]] << " ";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
512 KB |
Output is correct |
5 |
Correct |
19 ms |
1408 KB |
Output is correct |
6 |
Correct |
52 ms |
3576 KB |
Output is correct |
7 |
Correct |
104 ms |
5624 KB |
Output is correct |
8 |
Correct |
145 ms |
5752 KB |
Output is correct |
9 |
Correct |
695 ms |
26360 KB |
Output is correct |
10 |
Correct |
1513 ms |
42364 KB |
Output is correct |