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 "perm.h"
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define f0(i, n) for(int i = 0; i < (n); i++)
#define f1(i, n) for(int i = 1; i <= (n); i++)
#define ff first
#define ss second
#define pb push_back
std::vector<int> construct_permutation(long long k)
{
vector<int> res;
// if (k <= 90) {
// f0(i, k-1) res.pb(k-2-i);
// return res;
// }
k--;
long long cur = -1;
while(k > 0) {
long long m = 0;
long long po = 1;
while(2*po - 1 <= k) {
po *= 2;
m++;
}
k -= (po-1);
for(long long i = m; i > 0; i--) res.pb(cur+i);
cur += m;
}
return vector(res.rbegin(), res.rend());
return {};
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |