# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
897241 | 2024-01-02T19:26:07 Z | d4xn | Permutation (APIO22_perm) | C++17 | 1 ms | 436 KB |
#include "perm.h" #include <bits/stdc++.h> using namespace std; #define ll long long const int N = 5000, M = 100; const ll L = 62; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); vector<int> gen(vector<int> vt) { sort(vt.rbegin(), vt.rend()); vector<int> p; for (int& i : vt) { //cerr << i << endl; if (p.empty()) { for (int j = 0; j < i; j++) { p.push_back(j); //cerr << "a " << j << endl; } } else { for (int j = i; j < p.size(); j++) { p[j]++; } p.push_back(p[i]-1); //cerr << "b " << p[i]-1 << endl; } } return p; } vector<int> construct_permutation(ll k) { vector<int> p, p2, vt; if (!k) return p; vt.clear(); for (int j = L; j >= 0; j--) { if ((k >> j) & 1) { vt.push_back(j); } } p2 = gen(vt); if (p.empty() || p2.size() < p.size()) swap(p, p2); return p; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 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 | 348 KB | Output is correct |
8 | Partially correct | 1 ms | 348 KB | Partially correct |
9 | Correct | 1 ms | 436 KB | Output is correct |
10 | Partially correct | 1 ms | 348 KB | Partially correct |
11 | Partially correct | 1 ms | 348 KB | Partially correct |
12 | Partially correct | 1 ms | 348 KB | Partially correct |
13 | Partially correct | 1 ms | 348 KB | Partially correct |