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>
#include "perm.h"
using namespace std;
typedef long long i64;
typedef vector<int> vi;
const int mxLOG = 62;
vi construct_permutation(i64 K) {
i64 k = K - 1;
int n = 0; vi t, a;
for(int i = mxLOG - 1; i >= 1; i--) {
i64 cnt = (1LL << i) - 1LL;
while(k >= cnt) {
k -= cnt;
n += i;
t.push_back(i);
// cout << " size: " << i << endl;
}
}
int en = n - 1;
for(int cnt : t) {
int st = en - cnt + 1;
for(int i = st; i <= en; i++)
a.push_back(i);
en = st - 1;
}
// for(int x : a)
// cout << x << ' ';
// cout << endl;
return a;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |