Submission #1199850

#TimeUsernameProblemLanguageResultExecution timeMemory
1199850ByeWorldPermutation (APIO22_perm)C++20
91.33 / 100
1 ms328 KiB
#include "perm.h"
#include <bits/stdc++.h>
#define ll long long
#define se second
#define fi first
#define pb push_back
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
using namespace std;
typedef pair<ll,ll> pii;
typedef pair<pii,ll> ipii;
const int MAXN = 8e5+15;
const int SQRT = 560;
const int INF = 1e9+10;
const int MOD = 998244353;
const int LOG = 20;

vector<int> ANS;

std::vector<int> construct_permutation(long long k){
	ANS.clear();
	k--;
	if(k==0) return {};
	int tot = 0;
	while((1ll<<tot) <= k){ // bisa dikurangin kurangin
		k -= (1ll<<tot);
		ANS.pb(tot++);
	}
	// for(auto in : ANS) cout << in << ' ';
	// 	cout << " xx\n";
	while(k){
		int big = log2l(k);
		k -= (1ll<<big);
		ANS.emplace(ANS.begin()+big, tot++);
	}
	// for(auto in : ANS) cout << in << ' ';
	// 	cout << " p\n";
	return ANS;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...