제출 #821369

#제출 시각아이디문제언어결과실행 시간메모리
821369radaiosm7순열 (APIO22_perm)C++17
64.62 / 100
10 ms1404 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; vector<int> construct_permutation(long long k) { --k; vector<int> groups; int sum = 0; vector<int> ans; long long po[61]; po[0] = 1LL; for (int i=1; i <= 59; ++i) po[i] = po[i-1]*2LL; for (int i=59; i >= 1; --i) { if (k >= po[i]) { k -= po[i]; groups.push_back(i); sum += i; ++k; } } while (k > 0LL) { groups.push_back(1); --k; ++sum; } --sum; int n = (int)groups.size(); for (int i=0; i < n; ++i) { int from = sum-groups[i]+1; for (int j=from; j <= sum; ++j) ans.push_back(j); sum = from-1; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...