Submission #976231

# Submission time Handle Problem Language Result Execution time Memory
976231 2024-05-06T10:22:01 Z rythm_of_knight Permutation (APIO22_perm) C++17
91.3333 / 100
2 ms 492 KB
#include "perm.h"
#include <vector>
#include <algorithm>
std::vector<int> construct_permutation(long long k) {
	#define int long long
	using namespace std;
    int temp = --k;
    vector <int> v;
    while (temp) {
        v.push_back(temp & 1);
        temp >>= 1;
    }
    int sz = v.size();
    for (int i = 0; i < sz; i++) {
        while (i > 0 && v[i - 1] == 0 && v[i] > 0) {
            v[i - 1] += 2;
            v[i]--;
            i--;
        }
    }
    int cnt = -1;
    vector <signed> ans;
    vector <signed> keyin;
    for (int i = 0; i < sz; i++) {
        vector <int> t;
        if (v[i] == 0)
            continue;
        while (--v[i]) {
            keyin.push_back(++cnt);
        }
        ans.push_back(++cnt);
    }
    reverse(keyin.begin(), keyin.end());
    for (signed &u : keyin)
        ans.push_back(u);
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 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 348 KB Output is correct
8 Partially correct 2 ms 344 KB Partially correct
9 Correct 1 ms 344 KB Output is correct
10 Partially correct 1 ms 348 KB Partially correct
11 Partially correct 1 ms 492 KB Partially correct
12 Partially correct 2 ms 348 KB Partially correct
13 Partially correct 1 ms 348 KB Partially correct