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<bits/stdc++.h>
#include "perm.h"
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using PP = pair<ll, P>;
const ll n_ =4e5+100, inf = (ll)2e9 * (ll)1e9 + 7, mod = 998244353;
ll n, m, tc = 1, a, b, c, d, sum, x, y, z, base, ans, k;
ll gcd(ll x,ll y){
if(!y)return x;
return gcd(y,x%y);
}
vector<int> construct_permutation(long long k){
vector<int>res,A;
sum=0;
x=k-1;
while(x){
bool flag=0;
for(int i=59;i>=1;i--){
a=(1ll<<i);
if(x>=a-1){
x-=a-1;
A.push_back(i);
sum+=i;
break;
}
}
}
for(auto nxt:A){
sum-=nxt;
for(int i=0;i<nxt;i++)res.push_back(sum+i);
}
return res;
}
Compilation message (stderr)
perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:23:14: warning: unused variable 'flag' [-Wunused-variable]
23 | bool flag=0;
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |