# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
722116 | yeyso | 순열 (APIO22_perm) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#include "perm.h"
#define int long long;
vector<int> construct_permutation(long long k)
{
k -= 1;
int x = 1;
vector<int> sub = {0};
vector<int> res;
while(sub[sub.size()-1] < k * 2){
sub.push_back(pow(2, x)-1);
x += 1;
}
while(k > 0){
for(int i = 0; i < sub.size(); i ++){
if(sub[i] > k){
k -= sub[i-1];
res.push_back(i-1);
break;
}
}
}
vector<vector<int>> inc;
int res0;
for(int i = 0; i < res.size(); i ++){
inc.push_back({});
for(int j = 0; j < res[i]; j ++){
inc[i].push_back(j+res0);
}
res0 += res[i];
}
vector<int> res2;
reverse(inc.begin(), inc.end());
for(int i = 0; i < inc.size(); i ++){
for(int j = 0; j < inc[i].size(); j ++){
res2.push_back(inc[i][j]);
}
}
return res2;
}