Submission #1065492

#TimeUsernameProblemLanguageResultExecution timeMemory
1065492GangstaPermutation (APIO22_perm)C++17
71.22 / 100
8 ms1508 KiB
#include "bits/stdc++.h" #define ll long long int #define pb push_back #define pii pair<int,int> #define ff first #define ss second #define sz size() using namespace std; ll tap(int n){ ll sum = (1LL<<n); return sum-1; } vector <int> construct_permutation(ll k){ k--; int cnt = 0; deque <int> d; vector <int> v; while(k>0){ int l = 1, r = 58, md, jog = -1; ll jog1 = -1; while(l <= r){ md = (l+r)/2; ll san = tap(md); if(san <= k){ jog = md; jog1 = san; l = md + 1; } else r = md - 1; } if(jog != -1){ k -= jog1; for(int i = cnt+jog-1; i >= cnt; i--) d.push_front(i); cnt += jog; } } while(!d.empty()){ v.pb(d.front()); d.pop_front(); } return v; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...