제출 #1112218

#제출 시각아이디문제언어결과실행 시간메모리
1112218ortsac순열 (APIO22_perm)C++17
0 / 100
1 ms336 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...