# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
138850 | win11905 | Ancient Books (IOI17_books) | C++11 | 250 ms | 27640 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "books.h"
#define long long long
using namespace std;
const int N = 1e6+5;
long ans = 0;
int n, x, y;
int id[N], L[N], R[N], ptr;
bool check[N];
void extend(int &l, int &r) {
int ll = min(L[id[l]], L[id[r]]);
int rr = max(R[id[l]], R[id[r]]);
while(ll < l || r < rr) {
if(ll < l) l--;
else r++;
ll = min(ll, min(L[id[l]], L[id[r]]));
rr = max(rr, max(R[id[l]], R[id[r]]));
}
}
long minimum_walk(vector<int> p, int s) {
n = p.size();
x = y = s;
for(int i = 0; i < n; ++i) ans += abs(i - p[i]);
for(int i = 0; i < n; ++i) if(!check[i]) {
id[i] = ++ptr, check[i] = true;
L[ptr] = R[ptr] = i;
# | 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... |