#include<bits/stdc++.h>
using namespace std;
const int nmax=1e6+42;
int where[nmax];
bool been[nmax];
long long minimum_walk(vector<int> p, int s)
{
int n=p.size();
for(int i=0;i<n;i++)
where[i]=p[i];
long long ans=0;
int last=0;
for(int i=0;i<n;i++)
if(been[i]==0)
{
ans=ans+i-last;
last=i;
int now=i;
while(been[now]==0)
{
ans=ans+abs(now-where[now]);
been[now]=1;
now=where[now];
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
3rd lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
3rd lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
3rd lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
488 KB |
3rd lines differ - on the 1st token, expected: '3304', found: '3740' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
3rd lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |