Submission #1048537

# Submission time Handle Problem Language Result Execution time Memory
1048537 2024-08-08T08:10:55 Z Gromp15 Ancient Books (IOI17_books) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
#include "books.h"
using namespace std;

long long minimum_walk(std::vector<int> p, int s) {
	int n = p.size();
	vector<bool> vis(n);
	long long ans = 0;
	int lst = 0;
	for (int i = 0; i < n; i++) if (!vis[i]) {
		ans += 2 * (i - lst);
		int tmp = i;
		long long cur = 0;
		while (!vis[tmp]) {
			cur += abs(tmp - p[tmp]), vis[tmp] = 1, tmp = p[tmp];
		}
		lst = tmp;
		ans += cur;
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 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 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 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 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 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 0 ms 344 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 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -