Submission #767641

# Submission time Handle Problem Language Result Execution time Memory
767641 2023-06-27T01:22:40 Z SanguineChameleon Ancient Books (IOI17_books) C++17
0 / 100
1 ms 212 KB
#include "books.h"
#include <bits/stdc++.h>
using namespace std;

long long minimum_walk(vector<int> p, int s) {
	int n = p.size();
	vector<bool> flag(n);
	long long res = 0;
	int mx = 0;
	for (int i = 0; i < n; i++) {
		if (!flag[i]) {
			mx = max(mx, i);
			int cur = i;
			while (true) {
				flag[cur] = true;
				res += abs(cur - p[cur]);
				cur = p[cur];
				if (cur == i) {
					break;
				} 
			}
		}
	}
	res += mx * 2;
	return res;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB 3rd lines differ - on the 1st token, expected: '3304', found: '4736'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -