Submission #725190

#TimeUsernameProblemLanguageResultExecution timeMemory
725190Batorgil952Permutation (APIO22_perm)C++17
0 / 100
1 ms212 KiB
#include<bits/stdc++.h>
#include "perm.h"

using namespace std;

std::vector<int> construct_permutation(long long k)
{
	vector< int > v;
	
	long long a[62], b[62];
	long long m=k, f=-1, r;
	for(long long i=0; i<=59; i++){
		if(m%2==1){
			a[i]=1;
		}
		m/=2;
	}
	for(long long i=59; i>=0; i--){
		if(a[i]>0){
			if(f==-1){
				f=i;
				r=f;
			}
			else{
				b[i]=f;
				f++;
			}
		}
	}
	for(long long i=0; i<=59; i++){
		if(b[i]>0) v.push_back(b[i]);
		if(i<r) v.push_back(i);
	}
	return v;
}

Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:32:3: warning: 'r' may be used uninitialized in this function [-Wmaybe-uninitialized]
   32 |   if(i<r) v.push_back(i);
      |   ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...