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 <cstdio>
#include <vector>
#include <cassert>
#include <cstdlib>
using namespace std;
bool isSubtask3(int s) { return s==0;}
long long subtask3(vector<int> p, int s) {
int n = p.size(), last = 0;
long long total = 0;
for(int i=0; i<n; i++) {
if (i==p[i]) continue;
if(i>last) total += (i-last)*2;
total += abs(p[i]-i);
last = max(last,p[i]);
}
return total;
}
long long fulltask(vector<int> p, int s) {
return 0;
}
long long minimum_walk(std::vector<int> p, int s) {
if (isSubtask3(s)) return subtask3(p,s);
return fulltask(p,s);
}
# | 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... |