Submission #671059

#TimeUsernameProblemLanguageResultExecution timeMemory
671059arnold518Permutation (APIO22_perm)C++17
91.33 / 100
2 ms340 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; ll K; std::vector<int> construct_permutation(long long _k) { K=_k; vector<int> ans, V; ll t=K; int cnt=0; for(int i=0; i<30 && t; i++) { if(t<4) { cnt+=t-1; for(int j=1; j<t; j++) ans.push_back(--cnt); } else if(t%4) { cnt+=4; for(int j=t%4-1; j<3; j++) ans.push_back(--cnt); V.push_back(--cnt); for(int j=0; j<t%4-1; j++) ans.push_back(--cnt); cnt+=4; } else { cnt+=3; ans.push_back(--cnt); ans.push_back(--cnt); ans.push_back(--cnt); cnt+=3; } t/=4; } while(!V.empty()) ans.push_back(V.back()), V.pop_back(); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...