Submission #912388

# Submission time Handle Problem Language Result Execution time Memory
912388 2024-01-19T11:16:50 Z huyngo Permutation (APIO22_perm) C++17
91.3333 / 100
2 ms 600 KB
#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 k) {
	vector<int> ans;
	int l = 0, r = 0;
	auto work = [&](auto self, ll x) -> void {
		if (x == 1) return;
		if (x & 1) {
			self(self, x - 1);
			ans.push_back(--l);
		}
		else {
			self(self, x >> 1);
			ans.push_back(++r);
		}
		};
	work(work, k);
	vector<int> s = ans;
	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 time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Partially correct 2 ms 348 KB Partially correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Partially correct 2 ms 600 KB Partially correct
9 Correct 2 ms 348 KB Output is correct
10 Partially correct 2 ms 416 KB Partially correct
11 Partially correct 2 ms 348 KB Partially correct
12 Partially correct 2 ms 348 KB Partially correct
13 Partially correct 2 ms 348 KB Partially correct