제출 #731795

#제출 시각아이디문제언어결과실행 시간메모리
731795hoainiem순열 (APIO22_perm)C++17
0 / 100
1 ms212 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; long long k, sum = 1; vector<long long>f; vector<int> ans; long long get(long long cur, long long x){ if (x >= 60) return 1LL << 60; if (k / cur < (1 << x)) return cur * (1 << x); return 1LL << 60; } std::vector<int> construct_permutation(long long K){ ans.clear(); f.clear(); k = K; f.push_back(1); ans.push_back(0); sum = 1; for (int i = 1; sum < k; i++){ if (sum * 2 <= k){ ans.push_back(i); f.push_back(sum); sum <<= 1; continue; } for (long long j = (int)f.size() - 1, d = sum; j > 0; j--){ d -= f[j]; if (sum + d <= k){ sum += d; ans.insert(ans.begin() + j, i); f.insert(f.begin() + j, d); } } } ans.erase(ans.begin()); for (int i = 0; i < (int)ans.size(); i++) ans[i]--; return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...