Submission #1177986

#TimeUsernameProblemLanguageResultExecution timeMemory
1177986KasymK순열 (APIO22_perm)C++17
91.33 / 100
1 ms328 KiB
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i)
#define wr puts("----------------")
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

vector<int> construct_permutation(ll k){
    vector<int> A;
    int a=0, b=-1;
    bool did=0;
    for(int i = 60; i >= 0; --i){
        if(did){
            A.pb(a++);
            if(k>>i&1)
                A.pb(b--);
        }
        did|=(k>>i&1);
    }
    unordered_map<int, int> mp;
    vector<int> v(all(A));
    sort(all(v));
    int op=-1;
    tr(it, v)
    mp[*it]=++op;
    v.clear();
    tr(it, A)
    v.pb(mp[*it]);
    return v;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...