# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
698418 | Cyanmond | Abracadabra (CEOI22_abracadabra) | C++17 | 1585 ms | 524288 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
int main() {
// O(N^2)
int N, Q;
std::cin >> N >> Q;
std::vector<int> P(N);
for (auto &e : P) {
std::cin >> e;
--e;
}
std::vector<std::vector<int>> states;
states.push_back(P);
while (true) {
const auto &a = states.back();
std::vector<int> x, y;
std::copy(a.begin(), a.begin() + (N / 2), std::back_inserter(x));
std::copy(a.begin() + (N / 2), a.end(), std::back_inserter(y));
std::vector<int> nextPerm;
int j = 0;
for (int i = 0; i < N / 2; ++i) {
while (j != N / 2 and y[j] < x[i]) {
nextPerm.push_back(y[j++]);
}
nextPerm.push_back(x[i]);
}
while (j != N / 2) {
nextPerm.push_back(y[j++]);
}
if (nextPerm == a) {
break;
}
states.push_back(nextPerm);
}
while (Q--) {
int t, i;
std::cin >> t >> i;
--i;
if (t < states.size()) {
std::cout << states[t][i] + 1 << std::endl;
} else {
std::cout << states.back()[i] + 1 << std::endl;
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |