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>
using namespace std;
#define ll long long
const ll Log=15;
#define MAX 1e18
#define MOD 1000000007
typedef pair<ll,ll> LP;
#define ld long double
vector<ll>seq;
ll cur=1;
void bm(ll num){
if(num==0){
return;
}
if(num&1){
bm(num/2);
seq.push_back(cur);
cur++;
}
else{
bm((num-1)/2);
seq.push_back(cur);
cur++;
seq.push_back(-cur);
}
}
vector<int> construct_permutation(ll n){
bm(n-1);
// cout<<seq.size()<<'\n';
vector<ll>seq2;
for(auto& u: seq){
seq2.push_back(u);
}
sort(seq2.begin(),seq2.end());
vector<int>ans;
for(auto& u: seq){
ans.push_back(lower_bound(seq2.begin(),seq2.end(),u)-seq2.begin());
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |