# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
954489 | horiseun | Permutation (APIO22_perm) | C++17 | 12 ms | 1628 KiB |
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 <iostream>
#include <vector>
#include <algorithm>
#include "perm.h"
using namespace std;
#define ll long long
vector<int> construct_permutation(ll k) {
vector<ll> pwrs;
pwrs.push_back((ll) 1);
for (int i = 0; i < 59; i++) {
pwrs.push_back(pwrs.back() * 2);
}
vector<int> szs;
for (int i = pwrs.size() - 1; i >= 0; i--) {
if (k >= pwrs[i]) {
szs.push_back(i);
k -= pwrs[i];
}
}
/*
for (int i = 0; i < szs.size(); i++) {
cout << szs[i] << "\n";
}
*/
vector<int> ret;
int curr = 0;
for (int i = 0; i < szs.size(); i++) {
for (int j = curr + szs[i] - 1; j >= curr; j--) {
ret.push_back(j);
}
curr += szs[i];
}
for (int i = 0; i < szs.size() - 1; i++) {
ret.push_back(curr + i);
}
reverse(ret.begin(), ret.end());
/*
for (int i = 0; i < ret.size(); i++) {
cout << ret[i] << " ";
}
cout << "\n";
*/
return ret;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |