Submission #1061355

#TimeUsernameProblemLanguageResultExecution timeMemory
1061355GangstaPermutation (APIO22_perm)C++17
10 / 100
1 ms428 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() const int N = 2e5 + 1; using namespace std; ll tap(int n){ ll sum = 0; for(int i = 0; i < n; i++){ ll x = (1<<i); sum += x; } return sum; } vector <int> construct_permutation(ll k){ k--; int cnt = 0; deque <int> d; vector <int> v; while(k>0){ int l = 1, r = 59, 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...