Submission #1112219

#TimeUsernameProblemLanguageResultExecution timeMemory
1112219ortsacPermutation (APIO22_perm)C++17
91.33 / 100
3 ms504 KiB
#include <bits/stdc++.h>
#include "perm.h"

#define int long long

using namespace std;

vector<int32_t> construct_permutation(int k) {
	deque<int> ans;
	k--;
	while (k > 0) {
		if (1LL & k) {
			ans.push_back(0);
			k = (k >> 1LL);
		} else {
			ans.push_back(1);
			k--;
		}
	}
	int curr = 0;
	int t = ans.size();
	vector<int32_t> tans(t);
	for (int i = 0; i < t; i++) {
		if (ans[i] == 0) tans[i] = (curr++);
	}
	for (int i = t - 1; i >= 0; i--) {
		if (ans[i] == 1) tans[i] = (curr++);
	}
	//for (auto u : tans) cout << u << " ";
	//cout << "\n";
	return tans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...