#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int x = (1<<n);
vector<int> nums(x);
map<int, int> cnt;
for (int i = 0; i < x; i++) {
cin >> nums[i];
cnt[nums[i]]++;
}
int cur = 0;
map<int, int> ans;
for (auto c : cnt) {
cur += c.second;
int temp = log2(cur);
ans[c.first] = n-temp;
}
for (int i = 0; i < x; i++) cout << ans[nums[i]] << ' ';
cout << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
15 ms |
1652 KB |
Output is correct |
6 |
Correct |
57 ms |
4948 KB |
Output is correct |
7 |
Correct |
86 ms |
7068 KB |
Output is correct |
8 |
Correct |
106 ms |
3956 KB |
Output is correct |
9 |
Correct |
535 ms |
37464 KB |
Output is correct |
10 |
Correct |
1098 ms |
54608 KB |
Output is correct |