제출 #993263

#제출 시각아이디문제언어결과실행 시간메모리
993263thelegendary08순열 (APIO22_perm)C++17
70.32 / 100
7 ms1116 KiB
#include "perm.h"
#include<bits/stdc++.h>
#define vi vector<int>
#define f0r(i, n) for(int i = 0;i<n;i++)
#define ll long long int
#define pb push_back
using namespace std;
static long long MX = 1e18;
std::vector<int> construct_permutation(long long k)
{
    k--;
    vi ans;
    vi nums;
    vi nums2;
    int ansl = 0;
    ll cur;
    for(int i = 59; i > 1; i--){
        cur = (1LL << i) + (1LL << (i - 1)) - 1;
        if(k > cur){
            k -= cur;
            ansl += i + 1;
            nums2.pb(i);
        }
    }
    for(int i = 59; i > 1; i--){
        cur = (1LL << i) - 1;
        if(k > cur){
            k -= cur;
            ansl += i;
            nums.pb(i);
        }
    }
    //for(auto u : nums)cout<<u<<' ';
    //cout<<'\n';
    //cout<<k<<'\n';
    int curr = ansl - 1;
    ansl += k - 1;
    f0r(i, k){
        ans.pb(ansl);
        ansl--;
    }
    for(auto u : nums){
        for(int i = curr - u + 1; i <= curr; i++)ans.pb(i);
        curr -= u;
    }
    for(auto u : nums2){
        for(int i = curr - u; i <= curr - 2; i++)ans.pb(i);
        ans.pb(curr);
        ans.pb(curr-1);
        curr -= (u + 1);
    }
    //for(auto u : ans)cout<<u<<' ';
    return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

perm.cpp:8:18: warning: 'MX' defined but not used [-Wunused-variable]
    8 | static long long MX = 1e18;
      |                  ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...