#include<bits/stdc++.h>
#include "books.h"
using namespace std;
long long a,b,c,d,e,i,j,ii,jj,zx,xc,f[1000009],S,bo[1000009],G[1000009],pas;
long long minimum_walk(std::vector<int> Pp, int Ss) {
a=Pp.size();S=Ss+1;
for(i=1; i<=a; i++) f[i]=Pp[i-1]+1;
for(i=1; i<=a; i++){
if(bo[i]==1) continue;
c=i;zx=i;
while(1){
bo[c]=1;zx=max(zx,c);
c=f[c];
if(c==i) break;
}
G[i]=(zx-c)*2LL;
}
zx=1;
for(i=1; i<=a; i++){
pas+=G[i];
if(G[i]!=0) zx=max(zx,i);
}
pas+=(zx-1)*2;
return pas;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
316 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
3rd lines differ - on the 1st token, expected: '8', found: '6' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
316 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
3rd lines differ - on the 1st token, expected: '8', found: '6' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
316 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
3rd lines differ - on the 1st token, expected: '8', found: '6' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
320 KB |
3rd lines differ - on the 1st token, expected: '3304', found: '4704' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
316 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
3rd lines differ - on the 1st token, expected: '8', found: '6' |
4 |
Halted |
0 ms |
0 KB |
- |