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>
#define sz size()
#define ll long long
using namespace std;
vector<int> construct_permutation(ll k)
{
ll z = 1;
--k;
vector<ll> x;
for(ll j = 59; j >= 0; --j)
{
if((z << j) - 1 > k) continue;
x.push_back(j);
k -= (z << j) - 1;
}
for(ll j = 59; j >= 0; --j)
{
if((z << j) - 1 > k) continue;
x.push_back(j);
k -= (z << j) - 1;
}
reverse(x.begin(), x.end());
ll cur = 0;
vector<int> ans;
for(ll t : x)
{
for(ll i = cur + t; i > cur; --i)
ans.push_back(i);
cur += t;
}
reverse(ans.begin(), ans.end());
return ans;
}
//signed main()
//{
// ios_base::sync_with_stdio(0);
// cin.tie(0), cout.tie(0);
// for(auto i : construct_permutation(9))
// cout << i << ' ';
//}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |