Submission #969616

#TimeUsernameProblemLanguageResultExecution timeMemory
969616dubabubaPermutation (APIO22_perm)C++17
91.33 / 100
2 ms600 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) {
	vi a;
	for(int i = mxLOG - 1; i >= 0; i--) {
		if((k & (1LL << i)) != (1LL << i)) continue;
		if(a.size() == 0) {
			for(int j = 0; j < i; j++)
				a.push_back(j);
			continue;
		}

		for(int &x : a)
			if(x >= i)
				x++;
		a.push_back(i);
	}
	return a;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...