제출 #1353728

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

using namespace std;

#define ll long long

void recalculate_permutation(vector<int> &p)
{
    map<int, int> mp;
    int t=0;
    for (auto x:p) mp[x]=0;
    for (auto &[x, y]:mp) y=t++;
    for (int i=0; i<p.size(); i++) p[i]=mp[p[i]]; //cout<<p[i]<<' ';
    // cout<<'\n';
}

std::vector<int> construct_permutation(long long k)
{
    vector<int> b, res;
    while (k) b.push_back(k%2), k/=2;
    for (int i=b.size()-2; i>=0; i--)
    {
        res.push_back(1e9);
        if (b[i]) res.push_back(-1);
        recalculate_permutation(res);
    }
    return res;
}

/*
3 bit to encode one data
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...