#include "books.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 * 1000 + 23;
int mark[MAXN], cnt = 0, ans, jav;
long long minimum_walk(std::vector<int> p, int s) {
if (s != 0) return 0;
int n = p.size();
for (int i = 0; i < n; i++) if (p[i] != i && mark[i] == 0) {
int tmp = i, pre = i;
mark[i] = ++cnt;
while ((tmp = p[tmp]) != i) {
mark[tmp] = cnt;
jav += abs(pre - tmp);
pre = tmp;
}
ans = max(ans, i);
}
return jav + ans * 2;
}
//int main() {}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
3rd lines differ - on the 1st token, expected: '6', found: '4' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
3rd lines differ - on the 1st token, expected: '6', found: '4' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
3rd lines differ - on the 1st token, expected: '6', found: '4' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
3rd lines differ - on the 1st token, expected: '3304', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
3rd lines differ - on the 1st token, expected: '6', found: '4' |
2 |
Halted |
0 ms |
0 KB |
- |