이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "perm.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> construct_permutation(long long k)
{
int ch[1001],res[1001];
memset(ch,0,sizeof(ch));
memset(res,0,sizeof(res));
int mx=0;
int id=1;
k--;
while (k){
for (int i=0;i<=mx;i++)
if ((1LL<<i)<=k)
res[id]=i;
k-=(1LL<<res[id]);
if (res[id]==mx)
mx++;
id++;
}
id--;
for (int i=id;i>=1;i--){
int cnt=0;
res[i]++;
while (res[i]){
cnt++;
if (!ch[cnt])
res[i]--;
}
res[i]=cnt;
ch[cnt]=1;
}
vector <int> v;
for (int i=1;i<=id;i++)
v.push_back(res[i]-1);
return v;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |