답안 #984064

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
984064 2024-05-16T09:46:06 Z vjudge1 순열 (APIO22_perm) C++17
0 / 100
0 ms 348 KB
#include "perm.h"
#include<bits/stdc++.h>
#define sz size()
#define ll long long
using namespace std;

vector<int> construct_permutation(ll k)
{
    ll z = 1;
    --k;
    vector<ll> x;
    for(ll j = 59; j >= 0; --j)
    {
        if((z << j) - 1 > k) continue;
        x.push_back(j);
        k -= (z << j) - 1;
    }
    for(ll j = 59; j >= 0; --j)
    {
        if((z << j) - 1 > k) continue;
        x.push_back(j);
        k -= (z << j) - 1;
    }

    reverse(x.begin(), x.end());
    ll cur = 0;
    vector<int> ans;
    for(ll t : x)
    {
        for(ll i = cur + t; i > cur; --i)
            ans.push_back(i - 1);
        cur += t;
    }
    reverse(ans.begin(), ans.end());
    return ans;
}

//signed main()
//{
//    ios_base::sync_with_stdio(0);
//    cin.tie(0), cout.tie(0);
//    for(auto i : construct_permutation(3))
//        cout << i << ' ';
//}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -