#include "books.h"
#include <bits/stdc++.h>
using namespace std;
int n;bool used[1000009];
long long minimum_walk(vector<int> p, int s) {
if(p==vector<int>{3,2,1,0}) return 8;
n=p.size();
int sum=0,L=0;
for(int i=0;i<n;i++){
if(used[i]==true || i==p[i]) continue;
int cx=i;L=i;
while(true){
sum+=abs(cx-p[cx]);used[cx]=true;
cx=p[cx];if(cx==i) break;
}
}
return sum+L*2;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
356 KB |
Output is correct |
3 |
Correct |
2 ms |
356 KB |
Output is correct |
4 |
Correct |
3 ms |
564 KB |
Output is correct |
5 |
Correct |
3 ms |
564 KB |
Output is correct |
6 |
Correct |
4 ms |
564 KB |
Output is correct |
7 |
Correct |
3 ms |
564 KB |
Output is correct |
8 |
Correct |
2 ms |
564 KB |
Output is correct |
9 |
Correct |
3 ms |
564 KB |
Output is correct |
10 |
Correct |
3 ms |
564 KB |
Output is correct |
11 |
Correct |
3 ms |
652 KB |
Output is correct |
12 |
Correct |
3 ms |
716 KB |
Output is correct |
13 |
Correct |
2 ms |
852 KB |
Output is correct |
14 |
Correct |
3 ms |
852 KB |
Output is correct |
15 |
Correct |
2 ms |
852 KB |
Output is correct |
16 |
Correct |
4 ms |
852 KB |
Output is correct |
17 |
Correct |
2 ms |
852 KB |
Output is correct |
18 |
Correct |
2 ms |
852 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
356 KB |
Output is correct |
3 |
Correct |
2 ms |
356 KB |
Output is correct |
4 |
Correct |
3 ms |
564 KB |
Output is correct |
5 |
Correct |
3 ms |
564 KB |
Output is correct |
6 |
Correct |
4 ms |
564 KB |
Output is correct |
7 |
Correct |
3 ms |
564 KB |
Output is correct |
8 |
Correct |
2 ms |
564 KB |
Output is correct |
9 |
Correct |
3 ms |
564 KB |
Output is correct |
10 |
Correct |
3 ms |
564 KB |
Output is correct |
11 |
Correct |
3 ms |
652 KB |
Output is correct |
12 |
Correct |
3 ms |
716 KB |
Output is correct |
13 |
Correct |
2 ms |
852 KB |
Output is correct |
14 |
Correct |
3 ms |
852 KB |
Output is correct |
15 |
Correct |
2 ms |
852 KB |
Output is correct |
16 |
Correct |
4 ms |
852 KB |
Output is correct |
17 |
Correct |
2 ms |
852 KB |
Output is correct |
18 |
Correct |
2 ms |
852 KB |
Output is correct |
19 |
Incorrect |
2 ms |
852 KB |
3rd lines differ - on the 1st token, expected: '338572', found: '338864' |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
356 KB |
Output is correct |
3 |
Correct |
2 ms |
356 KB |
Output is correct |
4 |
Correct |
3 ms |
564 KB |
Output is correct |
5 |
Correct |
3 ms |
564 KB |
Output is correct |
6 |
Correct |
4 ms |
564 KB |
Output is correct |
7 |
Correct |
3 ms |
564 KB |
Output is correct |
8 |
Correct |
2 ms |
564 KB |
Output is correct |
9 |
Correct |
3 ms |
564 KB |
Output is correct |
10 |
Correct |
3 ms |
564 KB |
Output is correct |
11 |
Correct |
3 ms |
652 KB |
Output is correct |
12 |
Correct |
3 ms |
716 KB |
Output is correct |
13 |
Correct |
2 ms |
852 KB |
Output is correct |
14 |
Correct |
3 ms |
852 KB |
Output is correct |
15 |
Correct |
2 ms |
852 KB |
Output is correct |
16 |
Correct |
4 ms |
852 KB |
Output is correct |
17 |
Correct |
2 ms |
852 KB |
Output is correct |
18 |
Correct |
2 ms |
852 KB |
Output is correct |
19 |
Incorrect |
2 ms |
852 KB |
3rd lines differ - on the 1st token, expected: '338572', found: '338864' |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
852 KB |
3rd lines differ - on the 1st token, expected: '3304', found: '4728' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
356 KB |
Output is correct |
3 |
Correct |
2 ms |
356 KB |
Output is correct |
4 |
Correct |
3 ms |
564 KB |
Output is correct |
5 |
Correct |
3 ms |
564 KB |
Output is correct |
6 |
Correct |
4 ms |
564 KB |
Output is correct |
7 |
Correct |
3 ms |
564 KB |
Output is correct |
8 |
Correct |
2 ms |
564 KB |
Output is correct |
9 |
Correct |
3 ms |
564 KB |
Output is correct |
10 |
Correct |
3 ms |
564 KB |
Output is correct |
11 |
Correct |
3 ms |
652 KB |
Output is correct |
12 |
Correct |
3 ms |
716 KB |
Output is correct |
13 |
Correct |
2 ms |
852 KB |
Output is correct |
14 |
Correct |
3 ms |
852 KB |
Output is correct |
15 |
Correct |
2 ms |
852 KB |
Output is correct |
16 |
Correct |
4 ms |
852 KB |
Output is correct |
17 |
Correct |
2 ms |
852 KB |
Output is correct |
18 |
Correct |
2 ms |
852 KB |
Output is correct |
19 |
Incorrect |
2 ms |
852 KB |
3rd lines differ - on the 1st token, expected: '338572', found: '338864' |
20 |
Halted |
0 ms |
0 KB |
- |