# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
596663 | slime | Permutation (APIO22_perm) | C++17 | 3 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "perm.h"
#include "bits/stdc++.h"
using namespace std;
int fastlog(long long x) {
return (x == 0 ? -1 : 64 - __builtin_clzll(x) - 1);
}
std::vector<int> construct_permutation(long long k)
{
// x3: 2 0 1 "4 3"
// x6: 2 0 1 "4 3 5"
// +1: "3" 2 0 1
// +2: "4 3" 2 0 1
vector<int> cur = {};
vector<int> bit;
bool begin = 0;
long long pow3[38];
pow3[0] = 1;
for(int i=1; i<38; i++) pow3[i] = pow3[i-1] * 3;
long long kpr = k;
for(int i = 37; i >= 0; i--) {
if(kpr >= pow3[i]) {
bit.push_back(kpr / pow3[i]);
begin = 1;
kpr %= pow3[i];
}
else if(begin) bit.push_back(0);
}
if(bit[0] == 2) {
cur.push_back(0);
}
for(int i = 1; i < bit.size(); i++) {
int n = cur.size();
cur.push_back(n + 1);
cur.push_back(n);
for(int j = 0; j < bit[i]; j++) {
int n = cur.size();
vector<int> nw;
nw.push_back(n);
for(int x: cur) nw.push_back(x);
cur = nw;
}
}
return cur;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |