This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
vector<int> construct_permutation(ll k){
int len = 1;
while((1ll << len) < k) len++;
vector<int> ans, tmp;
for(int i = 1; i < len; ++i){
ans.pb(2 * i);
}
k -= (1ll << (len - 1));
for(int cur = 2 * len - 1, pw = 0; cur >= 1; cur -= 2, pw++){
if(k & (1ll << pw)) tmp.pb(cur);
}
for(auto x:ans) tmp.pb(x);
swap(ans, tmp);
vector<int> ls = ans;
sort(ls.begin(), ls.end());
for(auto &x:ans){
x = lower_bound(ls.begin(), ls.end(), x) - ls.begin();
}
return ans;
}
/*
int main(){
int q; cin >> q;
while(q--){
int k; cin >> k;
vector<int> v = construct_permutation(k);
for(auto x:v) cout << x << ' ';
cout << '\n';
}
}
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |