Guest User

Untitled

a guest
Feb 4th, 2017
137
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. #define maxn 500009
  3. #define inf 1000000007
  4. #define llinf 1000000000000000007
  5. #define ff first
  6. #define ss second
  7. #define mp make_pair
  8. #define pb push_back
  9. #define mid(a,b) (a+b)/2
  10. #define endl "\n"
  11. #define sz size()
  12. #define MOD 1000000007
  13. //#define M 100000
  14. #define pii pair<int,int>
  15. #define all(x) x.begin(),x.end()
  16. #define tr(i, c) for(typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
  17. using namespace std;
  18. typedef long long ll;
  19. //priority_queue < pii, vector< pii >, greater< pii > > Q;
  20.  
  21.  
  22.  
  23. map< int, int > M;
  24. int a[maxn], b[maxn];
  25.  
  26. int main(){
  27. ios_base::sync_with_stdio(false);
  28. cin.tie(NULL);
  29. int n, x, y;
  30. cin>>n;
  31. for(int i=1; i<=(1<<n); i++)
  32. cin>>a[i], b[i] = a[i];
  33. sort(a+1, a+(1<<n)+1);
  34. for(int i=1; i<=(1<<n); i++){
  35. x = a[i];
  36. y = log2(i);
  37. M[x] = max(M[x], y);
  38. // cout<<x<<" "<<y<<endl;
  39. }
  40. for(int i=1; i<=(1<<n); i++)
  41. cout<<n-M[b[i]]<<" ";
  42. cout<<endl;
  43.  
  44.  
  45. return 0;
  46. }
RAW Paste Data