# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
920941 | salmon | Ancient Books (IOI17_books) | C++14 | 1 ms | 1372 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(vector<int> p, int s) {
bool done[1100100];
int N = p.size();
int un = N;
int soom = 0;
/*while(un != 0){
if(start )
}*/
int big = 0;
for(int i = 0; i < N; i++){
if(done[i]) continue;
done[i] = true;
big = i;
int j = p[i];
soom += abs(j - i);
while(j != i){
int temp = j;
done[j] = true;
j = p[j];
soom += abs(temp - j);
}
}
return soom + 2 * big;
}
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... |