제출 #1353722

#제출 시각아이디문제언어결과실행 시간메모리
135372212345678순열 (APIO22_perm)C++17
91.33 / 100
1 ms344 KiB
#include "perm.h"
#include <bits/stdc++.h>

using namespace std;

#define ll long long

std::vector<int> construct_permutation(long long k)
{
    k-=1;
    vector<int> res;
    int idx=0;
    while ((1ll<<idx)<=k) k-=(1ll<<idx), res.push_back(idx), idx++;
    for (int i=60; i>=0; i--)
    {
        if (k&(1ll<<i))
        {
            // insert i+1 inside
            vector<int> newres;
            for (auto x:res) newres.push_back(x+(x>=i));
            newres.push_back(i);
            res=newres;
        }
    }
    return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...