Submission #767664

# Submission time Handle Problem Language Result Execution time Memory
767664 2023-06-27T02:59:15 Z SanguineChameleon Ancient Books (IOI17_books) C++17
0 / 100
1 ms 304 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]) {
			int sz = 0;
			int cur = i;
			while (true) {
				sz++;
				flag[cur] = true;
				res += abs(cur - p[cur]);
				cur = p[cur];
				if (cur == i) {
					break;
				} 
			}
			if (sz >= 2) {
				mx = max(mx, i);
			}
		}
	}
	res += mx * 2;
	return res;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Incorrect 1 ms 212 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Incorrect 1 ms 212 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Incorrect 1 ms 212 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 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: '4728'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Incorrect 1 ms 212 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -