Submission #1235122

#TimeUsernameProblemLanguageResultExecution timeMemory
1235122dizzy_groovyPermutation (APIO22_perm)C++20
0 / 100
1 ms324 KiB
#include "perm.h"
#include <bits/stdc++.h>

using namespace std;

std::vector<int> construct_permutation(long long k)
{
	vector<int> p;
	int cur = 1;
	for (int i = 0; (1 << (i + 1)) < k; i++) {
		cur *= 2;
		p.push_back(i);
	}
	int n = p.size();
	while (k - cur > 0) {
		int x = __lg(k - cur);
		for (int i = x; i < n; i++) {
			p[i]++;
		}
		p.push_back(x);
		cur += (1 << x);
	}
	return p;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...