Submission #969550

#TimeUsernameProblemLanguageResultExecution timeMemory
969550dubabubaPermutation (APIO22_perm)C++17
71.22 / 100
10 ms1432 KiB
#include <bits/stdc++.h>
#include "perm.h"

using namespace std;

typedef long long i64;
typedef vector<int> vi;

const int mxLOG = 62;

vi construct_permutation(i64 K) {
	i64 k = K - 1;
	int n = 0; vi t, a;
	for(int i = mxLOG - 1; i >= 1; i--) {
		i64 cnt = (1LL << i) - 1LL;
		while(k >= cnt) {
			k -= cnt;
			n += i;
			t.push_back(i);
			// cout << " size: " << i << endl;
		}
	}

	int en = n - 1;
	for(int cnt : t) {
		int st = en - cnt + 1;
		for(int i = st; i <= en; i++)
			a.push_back(i);
		en = st - 1;
	}

	// for(int x : a)
		// cout << x << ' ';
	// cout << endl;
	return a;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...