# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
41001 | alenam0161 | Ancient Books (IOI17_books) | C++14 | 232 ms | 111888 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "books.h"
#include <vector>
#include <algorithm>
using namespace std;
const int N = 1e6 + 7;
int group[N];
int mx[N];
bool used[N];
long long minimum_walk(std::vector<int> p, int s) {
long long ans = 0;
for (int i = 0; i < p.size(); ++i) {
int to = i;
if (used[to])continue;
while (true) {
group[to] = i;
mx[i] = max(mx[i], to);
ans += abs(p[to] - to);
used[to] = true;
if (used[p[to]])break;
to = p[to];
}
}
int Mx = 0;
for (int i = 0; i < p.size(); ++i) {
if (Mx == -1) { ans += 2; Mx = mx[i]; }
else {
Mx = max(Mx, mx[i]);
}
if (Mx == i)Mx = -1;
}
for (int i = p.size() - 1; i > 0; i--) { if (p[i] != i)break; ans -= 2; }
return ans;
}
컴파일 시 표준 에러 (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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |