Submission #969578

#TimeUsernameProblemLanguageResultExecution timeMemory
969578dubabubaPermutation (APIO22_perm)C++17
91.33 / 100
2 ms500 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;
	vi st, en;
	int n = 0;
	while(k) {
		if(k % 2 == 1) {
			st.push_back(n);
			k /= 2;
		}
		else {
			en.push_back(n);
			k--;
		}
		n--;
	}

	for(int &a : st) a = abs(a);
	for(int &b : en) b = abs(b);

	// cout << " st = "; for(int a : st) cout << a << ' '; cout << endl;
	// cout << " en = "; for(int a : en) cout << a << ' '; cout << endl;

	while(en.size()) {
		st.push_back(en.back());
		en.pop_back();
	}
	return st;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...