Submission #912385

#TimeUsernameProblemLanguageResultExecution timeMemory
912385huyngoPermutation (APIO22_perm)C++17
0 / 100
0 ms348 KiB
#include "perm.h"
#include <bits/stdc++.h>  
using namespace std;
using ll = long long;
using i64 = long long;
#define ln "\n"
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b) for(int i=a; i<=b; ++i)

const int mxN = 1e6 + 5;
int n;

vector<int> construct_permutation(long long x) {
	vector<int> ans;
	vector<int> s;
	int l = 0, r = 0;
	while (x > 1) {
		if (x & 1) {
			ans.push_back(--l);
			s.push_back(l);
			--x;
		}
		else {
			ans.push_back(++r);
			s.push_back(r);
			x >>= 1;
		}
	}
	sort(all(s));
	s.erase(unique(all(s)), s.end());
	for (int& i : ans)
		i = lower_bound(all(s), i) - s.begin();
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...