# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1076044 | mdn2002 | Ancient Books (IOI17_books) | C++17 | 1 ms | 348 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "books.h"
#include<bits/stdc++.h>
using namespace std;
long long minimum_walk(std::vector<int> p, int s) {
assert(s == 0);
long long ans = 0, n = p.size(), last = 0;
for (int i = 0; i < n; i ++) {
if (p[i] != i) {
ans += abs(last - i);
last = i;
int carry = p[i], j = i;
while (p[i] != i) {
ans += abs(carry - p[carry]);
swap(p[carry], carry);
}
}
}
ans += last;
return ans;
}
Compilation message (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... |