제출 #984124

#제출 시각아이디문제언어결과실행 시간메모리
984124vjudge1순열 (APIO22_perm)C++17
71.22 / 100
18 ms1372 KiB
#include "perm.h"
#include<bits/stdc++.h>
#define sz size()
#define ll long long
using namespace std;
mt19937_64 rnd(990910211394901);
vector<int> construct_permutation(ll k)
{
    ll z = 1, sum = 0;
    k;
    vector<ll> x;

    for(ll j = 59; j > 0; --j)
    {
        if((z << j) > k) continue;
        x.push_back(j);
        k -= (z << j);
        sum += j;
        break;
    }

    for(ll t = 1; t <= 1000; ++t)
        for(ll j = 59; j > 0; --j)
        {
            if((z << j) - 1 > k) continue;
            x.push_back(j);
            k -= (z << j) - 1;
            sum += j;
        }

    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);
//    ll n;
//    cin >> n;
//    for(auto i : construct_permutation(n))
//        cout << i << ' ';
//}

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

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:10:5: warning: statement has no effect [-Wunused-value]
   10 |     k;
      |     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...