//Sylwia Sapkowska
#include <bits/stdc++.h>
#include "perm.h"
#pragma GCC optimize("O3", "unroll-loops")
using namespace std;
void __print(int x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << "'" << x << "'";}
void __print(const char *x) {cerr << '"' << x << '"';}
void __print(const string &x) {cerr << '"' << x << '"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
typedef pair<int, int> T;
const int oo2 = 1e9+7, K = 30;
typedef long long ll;
vector<int> construct_permutation(ll k){
vector<int>ans;
function<void(ll)>rec = [&](ll n){
if (!n) return;
if (n&1) rec(n/2);
else rec(n-1);
int mx = 0, mn = 0;
for (auto x: ans) {
mx = max(mx, x);
mn = min(mn, x);
}
if (n&1) ans.emplace_back(mx+1);
else ans.emplace_back(mn-1);
};
rec(k-1);
debug(ans);
auto s = ans;
sort(s.begin(), s.end());
vector<int>ret;
for (int i = 0; i<(int)ans.size(); i++){
ret.emplace_back((int)(lower_bound(s.begin(), s.end(), ans[i])-s.begin()));
}
debug(ret);
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Partially correct |
1 ms |
348 KB |
Partially correct |
6 |
Correct |
1 ms |
436 KB |
Output is correct |
7 |
Correct |
2 ms |
496 KB |
Output is correct |
8 |
Partially correct |
2 ms |
348 KB |
Partially correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Partially correct |
2 ms |
348 KB |
Partially correct |
11 |
Partially correct |
2 ms |
348 KB |
Partially correct |
12 |
Partially correct |
2 ms |
500 KB |
Partially correct |
13 |
Partially correct |
2 ms |
348 KB |
Partially correct |