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 <iostream>
typedef long long llong;
int unused = 120;
std::vector < int > ans;
std::vector < int > construct_permutation(llong k)
{
ans.clear();
unused = 120;
bool flag = false;
for (int bit = 59 ; bit >= 0 ; --bit)
{
if ((k & (1LL << bit)) == 0) continue;
if (!flag)
{
flag = 1;
for (int i = unused - bit + 1 ; i <= unused ; ++i)
{
ans.push_back(i);
}
unused -= bit;
continue;
}
ans.insert(ans.begin() + (int)(ans.size() - bit), unused--);
}
for (int &i : ans) i -= unused + 1;
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |