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"
long long minimum_walk(std::vector<int> p, int s) {
int len=p.size();
int correct=true;
int count=0;
for(int i=len-1;i>0;i--)
{
if(p[i]!=i)
{
correct=false;
break;
}
count++;
}
if(correct==true) return 0;
else if(count==0 && len>3)
{
correct=true;
for(int i=len-1;i>0;i--)
{
if(p[i]!=len-i-1)
{
correct=false;
break;
}
}
if(correct==false)
{
int ans=len-count-1;
ans=ans+ans;
return ans;
}
else return 2*len;
}
else
{
int ans=len-count-1;
ans=ans+ans;
return ans;
}
}
# | 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... |