이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "perm.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
vector<int> construct_permutation(ll k)
{
if(k == 1) return {};
if(k % 2 == 1){
ll p = 1;
int leng = 0;
while(2ll * p <= k){
p *= 2ll;
leng ++ ;
}
if(p == k){
vector<int> z;
for(int i = 0 ; i < leng; i ++ ){
z.push_back(leng);
}
return z;
}
else{
p -- ;
k -= p;
vector<int> sol = construct_permutation(k);
vector<int> res;
for(int i = 0 ; i < leng; i ++ ){
res.push_back(sol.size() + i);
}
for(auto x : sol) res.push_back(x);
return res;
}
}
else{
vector<int> sol = construct_permutation(k / 2ll);
sol.push_back(sol.size());
return sol;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |