Submission #957591

#TimeUsernameProblemLanguageResultExecution timeMemory
957591vjudge1Permutation (APIO22_perm)C++17
0 / 100
0 ms348 KiB
#include <bits/stdc++.h>
// #include "perm.h"
using namespace std;

vector<int> construct_permutation(long long k){
	vector<int> ans;
	int cnt = 0; k--;
	for(int i = 59; i >= 0; i--){
		if(k >= (1ll<<(i+1)) - 1){
			int lcnt = cnt;
			cnt += i + 1;
			k -= (1ll<<(i+1)) - 1;
			for(int i = cnt; i > lcnt; i--){
				ans.push_back(i - 1);
			}
		}
	}
	if(k) ans.push_back(cnt);
	reverse(ans.begin(), ans.end());
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...