제출 #573131

#제출 시각아이디문제언어결과실행 시간메모리
573131dqhungdl순열 (APIO22_perm)C++17
10 / 100
1084 ms340 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; int pivot; vector<int> rs; void backtrack(long long k) { if (!k) return; int pw2 = 1, cnt = 0; while (pw2 * 2 - 1 <= k) { pw2 *= 2; cnt++; } for (int i = pivot - cnt + 1; i <= pivot; i++) rs.push_back(i); pivot -= cnt; backtrack(k - pw2 + 1); } std::vector<int> construct_permutation(long long k) { pivot = 1e9; rs.clear(); backtrack(k - 1); int minVal = *min_element(rs.begin(), rs.end()); // cout << minVal << '\n'; // for (int &x: rs) // cout << x << ' '; // cout << '\n'; for (int &x: rs) x -= minVal; return rs; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...