제출 #985489

#제출 시각아이디문제언어결과실행 시간메모리
985489Ghetto순열 (APIO22_perm)C++17
0 / 100
5 ms348 KiB
#include "perm.h" #include <bits/stdc++.h> using lint = long long; using namespace std; vector<int> normalise(vector<int> x, int n_pos) { int diff = x.size() - n_pos - 1; for (int& y : x) y += diff; return x; } vector<int> construct_permutation(lint k) { int max_bit = 0; for (int i = 0; i <= 60; i++) if (k & (lint) powl(2, i)) max_bit = i; assert(max_bit != 0); vector<int> ans; for (int i = 1; i <= max_bit; i++) ans.push_back(i); int prev = 1; for (int bit = 0; bit <= 60; bit++) { if (!(k & (lint) powl(2, bit))) continue; if (bit == max_bit) continue; prev--; int diff = max_bit - bit; for (auto it = ans.begin(); it != ans.end(); it++) { if (*it != diff) continue; ans.insert(next(it, 1), prev); break; } } // for (int x : ans) cout << x << " "; ans = normalise(ans, max_bit); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...