Submission #993158

#TimeUsernameProblemLanguageResultExecution timeMemory
993158thelegendary08Permutation (APIO22_perm)C++17
10 / 100
5 ms812 KiB
#include "perm.h" #include<bits/stdc++.h> #define vi vector<int> #define f0r(i, n) for(int i = 0;i<n;i++) #define ll long long int #define pb push_back using namespace std; std::vector<int> construct_permutation(long long k) { k--; vi ans; vi nums; int ansl = 0; ll cur; for(int i = 59; i > 1; i--){ cur = pow(2, i) - 1; if(k > (cur)){ k -= cur; ansl += i; nums.pb(i); } } //for(auto u : nums)cout<<u<<' '; //cout<<'\n'; int curr = ansl - 1; ansl += k - 1; f0r(i, k){ ans.pb(ansl); ansl--; } for(auto u : nums){ for(int i = curr - u + 1; i <= curr; i++)ans.pb(i); curr -= u; } //for(auto u : ans)cout<<u<<' '; return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...