# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
681156 | 2023-01-12T12:44:06 Z | QwertyPi | Permutation (APIO22_perm) | C++17 | 2 ms | 340 KB |
#include "perm.h" #include <bits/stdc++.h> using namespace std; std::vector<int> construct_permutation(long long k){ vector<int> ans; int l = 0, r = 1; int mn0 = -1, mn1 = -1; int b = 59; while(~k & (1LL << b)) b--; for(b--; b >= 0;){ if(b >= 1 && (k >> b - 1) % 2 && (k >> b) % 2 && mn0 != -1 && mn1 != -1){ ans.push_back(r++); ans.push_back(r++); ans[mn0]--; ans[mn1]--; ans.push_back(l + 2); l--; b -= 2; }else{ if((k >> b) % 2){ ans.push_back(r++); mn0 = mn1; mn1 = ans.size(); ans.push_back(l--); }else{ ans.push_back(r++); } b--; } } int mn = *min_element(ans.begin(), ans.end()); for(auto& i : ans) i -= mn; return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 2 ms | 296 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 300 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 2 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 2 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |