| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 370957 | KoD | 고대 책들 (IOI17_books) | C++17 | 1 ms | 492 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "books.h"
template <class T>
using Vec = std::vector<T>;
long long minimum_walk(Vec<int> p, int s) {
assert(s == 0);
const int n = (int) p.size();
Vec<bool> done(n);
long long ret = 0;
int max = 0;
for (int i = 0; i < n; ++i) {
ret += std::abs(p[i] - i);
if (!done[i]) {
if (p[i] != i) {
max = std::max(max, i);
}
int u = i;
while (!done[u]) {
done[u] = true;
u = p[u];
}
}
}
return ret + 2 * max;
}
| # | 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... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
