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 ll long long
const int N = 5e3+3, M = 2e2+2;
const ll L = 62;
vector<int> construct_permutation(ll k)
{
vector<int> p;
if (!k) return p;
k--;
int r = N;
//vector<int> p2;
for (int j = L; j > 0; j--) {
//cerr << k << " " << j << " " << (1ll << j) << " " << (1ll << j) - 1ll << endl;
if (k >= (1ll << j) - 1ll) {
k -= (1ll << j) - 1ll;
for (int l = 1; l <= j; l++) {
/*p2*/p.push_back(r-j+l);
}
//cerr << j << endl;
r -= j;
j = L+1;
}
}
/*if (p.empty() || p2.size() < p.size()) swap(p, p2);
}*/
int sz = p.size();
for (int i = 0; i < sz; i++) {
p[i] -= N-sz+1;
}
return p;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |