Submission #1011597

#TimeUsernameProblemLanguageResultExecution timeMemory
1011597dimashhhPermutation (APIO22_perm)C++17
0 / 100
1 ms348 KiB
#include "perm.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> ret,g;
int hsb(ll x){
	for(int i = 60;i >= 0;i--){
		if((x >> i) & 1) return i;
	}
}
vector<int> construct_permutation(long long k)
{
	ret.clear();
	g.clear();
	int f = hsb(k);
	for(int i = 0;i < f;i++){
		g.push_back(i);
	}
	for(int i = f - 1;i >= 0;i--){
		if((k >> i) & 1){
			for(int j = i;j < (int)g.size();j++){
				g[j]++;
			}
			ret.push_back(g[i] - 1);
		}
	}
	for(int j:ret){
		g.push_back(j);
	}
	return g;
}

Compilation message (stderr)

perm.cpp: In function 'int hsb(ll)':
perm.cpp:10:1: warning: control reaches end of non-void function [-Wreturn-type]
   10 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...