Submission #957680

# Submission time Handle Problem Language Result Execution time Memory
957680 2024-04-04T07:52:22 Z pragmatist Permutation (APIO22_perm) C++17
55.4308 / 100
17 ms 2024 KB
#include "perm.h"
#include<bits/stdc++.h>

using namespace std;

mt19937 rng(time(NULL));

std::vector<int> construct_permutation(long long k)
{
	vector<int> ans;
	k--;
	int n = 0;
	vector<pair<int, int> > v;
	while(k>0) {
		int j = -1;
		for(int i = 60; i >= 0; --i) {
			long long cur = (1ll<<i)-1;
			if(cur <= k) {
				j = i;
				break;
			}
		}
		int x = rng()%3;
		int i = max(0, j-x);
		n += i;
		v.push_back({n-i, n-1});
		long long cur = (1ll<<i)-1;
		k -= cur;
	}
	reverse(v.begin(), v.end());
	for(auto e : v) {
		int l = e.first;
		int r = e.second;
		for(int i = l; i <= r; ++i) {
			ans.push_back(i);
		}
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Partially correct 2 ms 348 KB Partially correct
4 Partially correct 2 ms 348 KB Partially correct
5 Partially correct 6 ms 860 KB Partially correct
6 Partially correct 7 ms 1112 KB Partially correct
7 Partially correct 13 ms 1372 KB Partially correct
8 Partially correct 14 ms 1884 KB Partially correct
9 Partially correct 3 ms 604 KB Partially correct
10 Partially correct 17 ms 2024 KB Partially correct
11 Partially correct 14 ms 1724 KB Partially correct
12 Partially correct 12 ms 1628 KB Partially correct
13 Partially correct 13 ms 1800 KB Partially correct