Submission #1364364

#TimeUsernameProblemLanguageResultExecution timeMemory
1364364not_amirPermutation (APIO22_perm)C++20
91.33 / 100
1 ms344 KiB
#include "perm.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

vector<int> construct_permutation(ll k)
{
	k--;
	vector<int> p;
	vector<ll> cnt;
	while (k) {
		ll c = 1;
		int i = 0;
		while (i < cnt.size()) {
			if (c + cnt[i] > k)
				break;
			c += cnt[i++];
		}
		k -= c;
		cnt.push_back(c);
		for (int &x : p)
			if (x >= i)
				x++;
		p.push_back(i);
	}
	return p;
}
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...