#include <iostream>
#include <algorithm>
#define DIM 2000000
using namespace std;
pair <int,int> v[DIM];
int sol[DIM],p[DIM];
int n,i,maxi,m,j;
int main (){
cin>>n;
m = n, n = (1<<n);
for (i=1;i<=n;i++){
cin>>v[i].first;
v[i].second = i;
}
for (i=2;i<=n;i++)
p[i] = p[i/2]+1;
sort (v+1,v+n+1);
j = 1;
for (i=1;i<=n;i++){
while (j < n && v[j+1].first <= v[i].first)
j++;
sol[v[i].second] = m-p[j];
}
for (i=1;i<=n;i++)
cout<<sol[i]<<" ";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
7 ms |
504 KB |
Output is correct |
5 |
Correct |
23 ms |
1016 KB |
Output is correct |
6 |
Correct |
47 ms |
1784 KB |
Output is correct |
7 |
Correct |
94 ms |
3320 KB |
Output is correct |
8 |
Correct |
174 ms |
6264 KB |
Output is correct |
9 |
Correct |
406 ms |
13188 KB |
Output is correct |
10 |
Correct |
815 ms |
25792 KB |
Output is correct |