제출 #973451

#제출 시각아이디문제언어결과실행 시간메모리
973451CDuong순열 (APIO22_perm)C++17
100 / 100
2 ms432 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; vector<int> construct_permutation(long long k) { vector<int> binary; while (k) { binary.push_back(k & 1); k >>= 1; } reverse(binary.begin(), binary.end()); deque<int> dq; int cnt = 0, sz = (int)binary.size(), cntt = 0; for (int i = 1; i < sz; ++i) { dq.emplace_back(cnt++); if (binary[i]) { if (i + 1 < sz and binary[i + 1] and cntt > 1) { dq.emplace_back(cnt++); dq.insert(dq.begin() + 2, cnt++); ++i; } else dq.emplace_front(cnt++), cntt++; } } return {dq.begin(), dq.end()}; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...