# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
978972 | rshohruh | Permutation (APIO22_perm) | C++17 | 2 ms | 600 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 "perm.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
std::vector<int> construct_permutation(long long k)
{
k--;
vector<int> a;
int cur = 0;
while((1ll<<a.size())-1 <= k) a.push_back(cur++);
a.pop_back(); --cur;
k -= (1ll<<a.size())-1;
int i = a.size()-1;
for(int i = a.size()-1; i >= 0; --i){
if((1ll<<i) <= k){
a.insert(a.begin()+i, cur++);
k -= (1ll<<i);
}
}
return a;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |