Submission #982788

#TimeUsernameProblemLanguageResultExecution timeMemory
982788vjudge1Permutation (APIO22_perm)C++17
91.33 / 100
1 ms348 KiB
#include "perm.h"
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
using lli=long long;
#define deb(x) cout<<#x<<": "<<x<<endl;
vector<int> construct_permutation(long long k)
{
	int cont=0;
	lli pow2=2;
	while(pow2*2<= k){
		pow2*=2;
		cont++;
	}

	k-=pow2;
	vector<int> ans;
	int cont2=cont+1;

	while(cont>=0){
		if(pow2<=k){
			ans.pb(cont2);
			cont2++;
			k-=pow2;
		}
		ans.pb(cont);
		cont--;
		pow2/=2;
	}
	if(k==1){
		ans.pb(cont2);
	}
	reverse(ans.begin(), ans.end());
//	deb(k);
	
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...