Submission #1088672

#TimeUsernameProblemLanguageResultExecution timeMemory
1088672Math4Life2020Permutation (APIO22_perm)C++17
10 / 100
192 ms262144 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using pii = pair<ll,ll>;
using ld = long double;

ll l2(ll x) {
	return (31-__builtin_clz(x));
}

vector<int> construct_permutation(ll KC) {
	ll K = KC;
	ll lk = l2(K);
	vector<pair<ld,int>> v1;
	for (ll i=0;i<lk;i++) {
		v1.push_back({(ld)i,i});
	}
	K -= (1LL<<lk);
	ll T = lk;
	while (K>0) {
		ll lv = l2(K);
		v1.push_back({((ld)lv-0.5),T++});
		K -= (1LL<<lv);
	}
	sort(v1.begin(),v1.end());
	vector<int> vout;
	for (auto A: v1) {
		vout.push_back(A.second);
	}
	return vout;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...