# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
644799 | Tenis0206 | 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 <bits/stdc++.h>
using namespace std;
int fr[100005];
vector<int> construct_permutation(long long k)
{
int nr = 0;
long long aux = k;
while(aux!=1)
{
++nr;
aux /= 2;
}
vector<int> suf;
for(int b=0;b<nr;b++)
{
if((k & (1LL<<b)) != 0)
{
suf.push_back(b + suf.size());
}
}
reverse(suf.begin(),suf.end());
for(auto it : suf)
{
++fr[it];
}
int cnt = 0;
vector<int> rez;
for(int i=1;i<=nr;i++)
{
while(fr[cnt])
{
++cnt;
}
rez.push_back(cnt);
++cnt;
}
for(auto it : suf)
{
rez.push_back(it);
}
for(int i=0;i<rez.size();i++)
{
fr[i] = 0;
}
return rez;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |