# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
968412 | 12345678 | Permutation (APIO22_perm) | C++17 | 2 ms | 348 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
int mx, cnt;
ll p[62];
vector<int> res, l;
std::vector<int> construct_permutation(long long k)
{
p[0]=1;
for (int i=1; i<62; i++) p[i]=p[i-1]*2;
mx=cnt=0;
res.clear();
l.clear();
ll tmp=k;
while (tmp>0)
{
if (tmp%2==1) mx=max(mx, cnt), l.push_back(cnt);
tmp/=2;
cnt++;
}
for (int i=0; i<mx; i++) res.push_back(i);
l.pop_back();
reverse(l.begin(), l.end());
for (auto x:l)
{
for (int i=x; i<res.size(); i++) res[i]++;
res.push_back(x);
}
//for (auto x:res) cout<<x<<' ';
//cout<<'\n';
return res;
}
//0 1 2 3 4 5
//1 2 4 8 16 32
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |