# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
983288 | Sir_Ahmed_Imran | Permutation (APIO22_perm) | C++17 | 1 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.
///~~~LOTA~~~///
#include "perm.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define append push_back
#define add insert
#define nl '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define terminator main
#define N 60
ll pwr[N];
vector<int> construct_permutation(ll n){
int m;
pwr[0]=1;
vector<int> u,v;
for(ll i=1;i<N;i++)
pwr[i]=pwr[i-1]*2LL;
for(int i=59;i>0;i--){
if(n<pwr[i]) continue;
n-=pwr[i];
if(v.empty()){
m=i;
for(int j=0;j<i;j++)
v.append(j);
continue;
}
u.append(v[m-i]);
for(int j=m-i;j<m;j++)
v[j]++;
}
if(n) u.append(v.back()+1);
reverse(all(u));
for(auto& i:v)
u.append(i);
return u;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |