Submission #1202864

#TimeUsernameProblemLanguageResultExecution timeMemory
1202864hengliaoPermutation (APIO22_perm)C++20
91.33 / 100
1 ms328 KiB
#include "perm.h"
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define pb push_back
#define vll vector<ll>
#define pll pair<ll, ll>

typedef long long ll;

namespace{
    const ll B=2;

    vll con;

    ll id(ll tar){
        return lower_bound(con.begin(), con.end(), tar)-con.begin();
    }
}

vector<int> construct_permutation(long long k)
{
	vll a;
    for(ll rep=0;rep<63-__builtin_clzll(k);rep++){
        a.pb(rep*B);
    }
    k-=(1LL<<(63-__builtin_clzll(k)));
    for(ll i=62;i>=0;i--){
        if(k&(1LL<<i)){
            a.pb((i-1)*B+1);
        }
    }
    con.clear();
    for(auto &it:a){
        con.pb(it);
    }
    sort(con.begin(), con.end());
    con.erase(unique(con.begin(), con.end()), con.end());
    for(ll i=0;i<(ll) a.size();i++){
        a[i]=id(a[i]);
    }
    vector<int> re;
    for(auto &it:a){
        re.pb(it);
    }
    return re;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...