# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
139153 | triplem5ds | Ancient Books (IOI17_books) | C++14 | 2 ms | 256 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<bits/stdc++.h>
#include "books.h"
using namespace std;
int cnt;
int solve(int idx, int picked, vector < int > &v){
if (picked == -1 && v[idx] != idx){
picked = v[idx];
v[idx] = -1;
}
if (picked == idx){
swap(v[idx], picked);
}
if(idx == v[idx])
cnt++;
if(cnt == v.size())
return 0;
if (picked > idx || picked == -1)
return solve(idx + 1, picked, v) + 1;
else
return solve(idx - 1, picked, v) + 1;
}
long long minimum_walk(std::vector<int> v, int s) {
return solve(s, -1, v);
return 0;
}
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... |