Submission #618056

#TimeUsernameProblemLanguageResultExecution timeMemory
618056LoboPermutation (APIO22_perm)C++17
91.33 / 100
2 ms344 KiB
#include "perm.h" #include<bits/stdc++.h> using namespace std; #define int long long vector<int32_t> construct_permutation(int k) { int dv = 1; deque<int> ans; if(k%3 == 0) { k/=3; dv = 3; } else if(k%5 == 0) { k/=5; dv = 5; } int lg = 0; for(int i = 0; i <= 60; i++) { if(k >= (1LL<<i)) lg = i; } for(int i = lg-1; i >= 0; i--) { ans.push_back((int) ans.size()); if(k&(1LL<<i)) ans.push_front((int) ans.size()); } //adiociona algo que multiplica por 3 agora if(dv == 3) { ans.push_back((int) ans.size()+1); ans.push_back((int) ans.size()-1); } if(dv == 5) { int x = ans.size(); ans.push_back(x+2); ans.push_back(x); ans.push_back(x+1); } vector<int32_t> vc; for(auto x : ans) { vc.push_back(x); } return vc; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...