Submission #969595

# Submission time Handle Problem Language Result Execution time Memory
969595 2024-04-25T10:44:38 Z akacool445k Permutation (APIO22_perm) C++17
91.3333 / 100
2 ms 496 KB
#include <bits/stdc++.h>
#include "perm.h"
using namespace std;
 
// #define int long long
#define ll long long
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL); cin.tie(NULL)

const double inf = 1e18 + 9;
const int mxn = 2e5 + 2;
const int mod = 1e9 + 7;
 
vector<int> construct_permutation(long long k) {
	vector<int> v;
	int cnt1 = 0;
	int cnt2 = 0;
	long long tmp = k;
	while(tmp > 1) {
		if(tmp % 2 == 0) {
			tmp = tmp / 2;
			cnt1++;
		} else {
			tmp--;
			cnt1++;
		}
	}
	cnt1--;
	while(k > 1) {
		if(k % 2 == 0) {
			k = k / 2;
			v.push_back(cnt1);
			cnt1--;
		} else {
			k--;
			v.push_back(cnt2);
			cnt2++;
		}
	}
	reverse(v.begin(), v.end());
	return v;
}
# 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 1 ms 348 KB Partially correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 496 KB Output is correct
8 Partially correct 2 ms 344 KB Partially correct
9 Correct 1 ms 348 KB Output is correct
10 Partially correct 2 ms 348 KB Partially correct
11 Partially correct 2 ms 348 KB Partially correct
12 Partially correct 2 ms 348 KB Partially correct
13 Partially correct 1 ms 348 KB Partially correct