#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
const int MOD=1e9+7;
long long num[63];
int lol(vector<int> arr){
int n=arr.size(),res=0;
for (int i=0;i<(1<<n);i++){
bool works=true;
int cur=-1;
for (int j=0;j<n;j++){
if (i&(1<<j)){
if (arr[j]<cur){
works=false;
break;
}
cur=arr[j];
}
}
if (works) res++;
}
return res;
}
vector<int> construct_permutation(long long k){
k--;
num[0]=1;
for (int i=1;i<63;i++){
num[i]=num[i-1]*2;
}
vector<int> ans;
vector<int> arr;
int whack=3;
for (int i=0;i<whack;i++) arr.pb(i);
do{
vector<int> res;
for (auto i:arr) res.pb(i);
int cur=whack;
long long tempk=k;
tempk-=lol(res);
while (tempk>0){
int pos=min((int)res.size(),62);
while (tempk<num[pos]) pos--;
res.insert(res.begin()+pos,cur);
tempk-=num[pos];
cur++;
}
if (ans.empty() || ans.size()>res.size()){
ans=res;
}
} while (next_permutation(arr.begin(),arr.end()));
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |