제출 #1336242

#제출 시각아이디문제언어결과실행 시간메모리
1336242MunkhErdene순열 (APIO22_perm)C++17
71.22 / 100
5 ms1348 KiB
#include "perm.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define _ << " " <<
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define ull unsigned long long
#define lll __int128
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define BlueCrowner ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
const ll mod = 1e9 + 7;
const ll mod1 = 998244353;
const ll naim = 1e9;
const ll max_bit = 60;
const ull tom = ULLONG_MAX;
const ll MAXN = 100005;
const ll LOG = 20;
const ll NAIM = 1e18;
const ll N = 2e6 + 5;
vector<int> construct_permutation(ll k) {
	vector<int> siz;
	while(k) {
		FORD(bit, 63, 0) {
			if(k & (1ll << bit)) {
				if(k - (1ll << bit) == 0) {
					k = 0;
					siz.pb(bit);
				}
				else {
					k -= (1ll << bit) - 1;
					siz.pb(bit);
				}
				break;
			}
		}
	}
	ll n = siz.size();
	vector<int> ans;
	FOR(i, 0, n) {
		ll x = siz[i];
		FOR(j, 0, x) ans.pb(j);
	}
    ll m = ans.size();
    ll cur = 0, pos = m - 1;
    FORD(i, n - 1, 0) {
        FOR(j, 0, siz[i]) {
            ans[pos] += cur;
            pos--;
        }
        cur += siz[i];
    }
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...