Submission #982785

# Submission time Handle Problem Language Result Execution time Memory
982785 2024-05-14T17:59:13 Z vjudge1 Permutation (APIO22_perm) C++17
0 / 100
1 ms 348 KB
#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 time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -