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>
using namespace std;
#define scd(t) scanf("%d", &t)
#define sclld(t) scanf("%lld", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long double ld;
vi construct_permutation(long long k)
{
vi vec;
int n = 0;
k--;
while(k) {
int lo = 1;
int hi = 60;
while(lo != hi) {
int mid = (lo+hi+1)/2;
if((1LL<<mid)-1<=k) {
lo = mid;
}
else hi=mid-1;
}
k-=(1LL<<lo)-1;
vec.pb(lo);
}
vi out;
int c = 0;
for(auto e : vec) {
for(int i=c+e-1; i>=c; i--) {
out.pb(i);
}
c+=e;
}
reverse(all(out));
// printf("%lld\n", k);
// for(auto e : out) printf("%d ", e);
// printf("\n");
return out;
}
Compilation message (stderr)
perm.cpp: In function 'vi construct_permutation(long long int)':
perm.cpp:31:6: warning: unused variable 'n' [-Wunused-variable]
31 | int n = 0;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |