Submission #983248

#TimeUsernameProblemLanguageResultExecution timeMemory
983248Sir_Ahmed_ImranPermutation (APIO22_perm)C++17
10 / 100
1 ms480 KiB
///~~~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){ pwr[0]=1; for(ll i=1;i<N;i++) pwr[i]=pwr[i-1]*2LL; ll m=log2(n); vector<int> u,v; for(int i=0;i<m;i++) v.append(i); n-=pwr[m]; for(int i=m-1;i>0;i--){ if(n<pwr[i]) continue; n-=pwr[i]; 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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...