Submission #777090

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
7770902023-07-08 16:08:57AlanPermutation (APIO22_perm)C++17
93.67 / 100
2 ms340 KiB
#include <bits/stdc++.h>
#include "perm.h"
using namespace std;
using ll = long long;
vector<int> solve1 (ll k) {
vector<int> ans, bin;
int l = 0, r = 120;
for (int i = 0; i < 60; i++) bin.push_back(!!((1LL<<i) & k));
while (!bin.back()) bin.pop_back();
int sz = bin.size();
for (int i = 0; i+1 < sz; i++) {
if (bin[i]) ans.push_back(r--);
ans.push_back(l++);
}
for (auto& x : ans) if (x >= l) x = x - (r-l+1);
return ans;
}
vector<int> solve2 (ll k) {
if (k <= 6) return {};
vector<int> res = {1, 0, 2};
ll cur = 6;
while (cur*2 < k) {
cur *= 2;
res.push_back(res.back()+1);
}
k -= cur;
for (int x = res.back(); x > 0; x--, cur /= 2) if (k >= cur) {
for (auto& y : res) if (y > x) y++;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...