#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef pair<lli,lli> pii;
#define dbg(x) cout<<#x<<" has a value of: "<<x<<"\n";
#define usize(x) (int)(x.size())
#define plist(x) for(int i=0;i<usize(x);i++)cout<<"eleman "<<i<<" = "<<x[i]<<"\n";
#define foreach(x) for(auto item:x)
#define fill(s,x) for(int i=0;i<x;i++)cin>>s[i];
#define in(veriler,a) (veriler.find(a)!=veriler.end())
#define btw(x,y,z) x>=y && x<=z
std::ostream& operator<<(std::ostream& os, pair<int,int> p) {
os << p.first << ", " << p.second;
return os;
}
int lgv(int x){
int i=0;
while(x/2>0){
x/=2;
i++;
}
return i;
}
int main(){
int n;
cin>>n;
map<lli,int> dz;
vector<lli> vals(1<<n);
for (int i = 0; i < 1<<n; i++)
{
lli a;
cin>>a;
vals[i]=a;
if(!dz.count(a))dz[a]=0;
dz[a]++;
}
int kh=0;
foreach(dz){
kh+=item.second;
dz[item.first]=lgv(kh);
}
for (int i = 0; i < 1<<n; i++)
{
cout<<n-dz[vals[i]]<<" ";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
420 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
504 KB |
Output is correct |
5 |
Correct |
29 ms |
1400 KB |
Output is correct |
6 |
Correct |
91 ms |
3984 KB |
Output is correct |
7 |
Correct |
156 ms |
5916 KB |
Output is correct |
8 |
Correct |
193 ms |
4852 KB |
Output is correct |
9 |
Correct |
1231 ms |
29396 KB |
Output is correct |
10 |
Correct |
2400 ms |
45328 KB |
Output is correct |