# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
613663 | drdilyor | Ancient Books (IOI17_books) | C++17 | 2 ms | 308 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "books.h"
#ifdef ONPC
#include "t_debug.cpp"
#else
#define debug(...) 42
#endif
#define sz(a) ((int)(a).size())
using namespace std;
using ll = long long;
const int INF = 1e9;
const ll INFL = 1e18;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(RANDOM);
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p) { return is >> p.first >> p.second; }
const int N = 2e5, LOGN = 17, MOD = 1e9+7;
long long minimum_walk(std::vector<int> p, int s) {
int n = sz(p);
vector<int> right(n), left(n);
for (int i = 0; i < n; i++) {
if (p[i] > i) right[i] = p[i] - i;
if (p[i] < i) left[i] = i - p[i];
}
vector<int> res = {0};
for (int step = 0; step < n; step++) {
bool found = false;
int cur = 0;
for (int i = cur; i < n; i++) {
if (right[i]) {
found = true;
right[i] = 0;
cur = i + right[i];
i += right[i] - 1;
}
if (left[i]) {
found = true;
cur = i;
}
}
res.push_back(cur);
for (int i = cur; i >= 0; i--) {
if (left[i]) {
left[i] = 0;
cur = i;
i -= left[i] - 1;
}
}
res.push_back(cur);
}
res.push_back(0);
ll distance = 0;
for (int i = 1; i < sz(res); i++) {
distance += abs(res[i] - res[i-1]);
}
return distance;
}
컴파일 시 표준 에러 (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... |