제출 #1112185

#제출 시각아이디문제언어결과실행 시간메모리
1112185PagodePaiva순열 (APIO22_perm)C++17
91.33 / 100
275 ms504 KiB
#include<bits/stdc++.h> #include "perm.h" using namespace std; vector <int> solve(long long k){ if(k == 1) return {}; if(k%2 == 0){ vector <int> ans = solve(k/2); ans.push_back(ans.size()); return ans; } vector <int> ans = solve(k-1); for(auto &x : ans){ x++; } ans.push_back(0); return ans; } vector <int> merge(vector <int> a, vector <int> b){ int tam = b.size(); for(auto &x : a){ x += tam; } for(auto x : b){ a.push_back(x); } return a; } vector <int> ssolve(long long k){ vector <int> v = solve(k); for(int i = 1;i <= min(k-1, 1010LL);i++){ vector <int> aux = merge(solve(i), solve(k-i+1)); if(aux.size()< v.size()) v = aux; } return v; } vector<int> construct_permutation(long long k){ vector <int> ans = ssolve(k); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...