# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
982950 | Muhammad_Aneeq | Permutation (APIO22_perm) | C++17 | 2 ms | 516 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 <vector>
#include <algorithm>
using namespace std;
vector<int> construct_permutation(long long k)
{
vector<int>bits;
for (int i=59;i>=0;i--)
{
if ((1ll<<i)&k)
bits.push_back(i);
}
reverse(begin(bits),end(bits));
int sz=bits.back()+bits.size()-1;
int st=0,en=sz-1;
vector<int>ans(sz,0);
int j=0;
for (int i=0;i<sz;i++)
{
if (j<bits.size()&&bits[j]==st)
ans[i]=en--,j++;
else
ans[i]=st++;
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |