# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
635909 | Minindu2006 | Permutation (APIO22_perm) | C++17 | 2 ms | 340 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
vector<int> ind(ll k)
{
vector<int> v;
while(k > 0)
{
v.push_back(k % 2);
k /= 2;
}
vector<int> ans;
for(int i=0;i<v.size();i++)
{
if(v[i])
ans.push_back(i);
}
return ans;
}
std::vector<int> construct_permutation(long long k)
{
vector<int> cur = ind(k), ans;
int n = cur.size();
for(int i=0;i<cur[n - 1];i++)
ans.push_back(i);
if(n == 1)
return ans;
cur.pop_back();
reverse(cur.begin(), cur.end());
int nxt = cur[n - 1];
for(int i=0;i<n - 1;i++)
{
ans.insert(ans.begin() + cur[i], nxt);
nxt++;
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |