제출 #888426

#제출 시각아이디문제언어결과실행 시간메모리
888426green_gold_dog순열 (APIO22_perm)C++17
10 / 100
1 ms348 KiB
#include<bits/stdc++.h> #include "perm.h" typedef long long ll; using namespace std; void add1(vector<int>& ans) { for (auto& i : ans) { i++; } ans.push_back(0); } void add3(vector<int>& ans) { ans.insert(ans.begin() + 2, ans.size()); } void mul2(vector<int>& ans) { ans.push_back(ans.size()); } std::vector<int> construct_permutation(long long k) { if (k <= 90) { vector<int> all; for (ll i = 0; i < k - 1; i++) { all.push_back(i); } reverse(all.begin(), all.end()); return all; } vector<ll> all; ll now = 1; while (now < k) { all.push_back(k / now % 2); now *= 2; } vector<int> ans; ans.push_back(1); ans.push_back(0); all.pop_back(); ll lst = all.back(); all.pop_back(); if (!lst) { lst = all.back(); all.pop_back(); add1(ans); if (lst) { add1(ans); } } while (!all.empty()) { lst = all.back(); all.pop_back(); mul2(ans); if (lst) { if (!all.empty() && all.back()) { all.pop_back(); mul2(ans); add3(ans); } else { add1(ans); } } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...