#pragma GCC optimize("unroll-loops,Ofast,O3")
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define spc << " " <<
#define endl "\n"
#define all(x) x.begin(), x.end()
#define int long long
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define st first
#define nd second
#define inf 1000000009
#define MOD 1000000007
#define lim 200005
using namespace std;
void solve(){
int n; cin >> n;
map<int, int> num;
map<int, int> ans;
int arr[(1<<n)+1];
for(int i=1; i<=(1<<n); i++){
int a; cin >> a;
arr[i]=a;
num[a]++;
}
int cur=0;
for(auto p:num){
cur+=p.nd;
cerr << p.st spc p.nd spc cur << endl;
ans[p.st] = n - floor(log2(cur));
}
for(int i=1; i<=(1<<n); i++) cout << ans[arr[i]] << " ";
}
signed main(){
ios_base::sync_with_stdio(false);cin.tie(0);
#ifdef Local
freopen("in","r",stdin);
freopen("out","w",stdout);
#endif
int t=1;
//cin >> t;
while(t--) solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
86 ms |
2228 KB |
Output is correct |
6 |
Correct |
333 ms |
6760 KB |
Output is correct |
7 |
Correct |
460 ms |
9736 KB |
Output is correct |
8 |
Correct |
172 ms |
4180 KB |
Output is correct |
9 |
Correct |
2857 ms |
51428 KB |
Output is correct |
10 |
Execution timed out |
3033 ms |
65540 KB |
Time limit exceeded |