Submission #1068855

#TimeUsernameProblemLanguageResultExecution timeMemory
1068855kilikumaPermutation (APIO22_perm)C++17
71.22 / 100
12 ms1372 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; vector<int> construct_permutation(long long k) { vector<int> ans; k --; vector<long long> puis(61, 1); for (int i = 1; i < 61; i ++) { puis[i] = puis[i - 1] * 2; } int cur = -1; for (int i = 60; i >= 1; i --) { while (puis[i] - 1 <= k) { for (int j = cur + i; j >= cur + 1; j --) { ans.push_back(j); } cur += i; k -= (puis[i] - 1); } } reverse(ans.begin(), ans.end()); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...