This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "perm.h"
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
using ll = long long;
using ld = long double;
using vi = vector<int>;
template <class T>
bool uin(T &a, T b) {
return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
return a < b ? (a = b, true) : false;
}
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
namespace sub1 {
bool eligible(ll k) { return k <= 90; }
vi construct_permutation(ll k) {
vi ans;
ford(i, k - 1) { ans.pb(i); }
return ans;
}
}
namespace sub2 {
bool eligible(ll k) { return 1; }
vi construct_permutation(ll k) {
k--;
vi vec;
for (int i = 62; i; i--) {
while (k >= (1LL << i) - 1) {
k -= (1LL << i) - 1;
vec.pb(i);
}
}
int n = accumulate(all(vec), 0);
vi ans;
for (auto d : vec) {
fore(i, n - d, n - 1) { ans.pb(i); }
n -= d;
}
return ans;
}
}
std::vector<int> construct_permutation(long long k) {
if (sub1::eligible(k)) {
return sub1::construct_permutation(k);
}
if (sub2::eligible(k)) {
return sub2::construct_permutation(k);
}
}
Compilation message (stderr)
perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:75:1: warning: control reaches end of non-void function [-Wreturn-type]
75 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |