Submission #429775

# Submission time Handle Problem Language Result Execution time Memory
429775 2021-06-16T09:28:35 Z kwongweng Ancient Books (IOI17_books) C++17
0 / 100
1 ms 204 KB
#include "books.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define pb push_back

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