Submission #1053553

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

const int THRESHOLD = 13;

long long minimum_walk(vector<int> p, int s) {
	int n = p.size();
	vector<int> res(n,-1);
	for(int i=0;i<n;i++)res[p[i]]=i;
	long long ans = 1e10;
	vector<int> curr(n);iota(curr.begin(), curr.end(),0);
	int currhand = 0;
	curr[0]=-1;
	function<void(int,long long,int)> calc = [&](int x,long long t,int moves) {
		if(moves>THRESHOLD)return;
		swap(currhand,curr[x]);
		if(curr==res) {
			ans = min(ans,t+x);
		} else for(int i=0;i<n;i++)if(i!=x) {
			calc(i,t+abs(x-i),moves+1);
		}
		swap(currhand,curr[x]);
	};
	calc(0,0,0);
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 41 ms 348 KB Output is correct
2 Correct 39 ms 348 KB Output is correct
3 Incorrect 49 ms 348 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 41 ms 348 KB Output is correct
2 Correct 39 ms 348 KB Output is correct
3 Incorrect 49 ms 348 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 41 ms 348 KB Output is correct
2 Correct 39 ms 348 KB Output is correct
3 Incorrect 49 ms 348 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2044 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 41 ms 348 KB Output is correct
2 Correct 39 ms 348 KB Output is correct
3 Incorrect 49 ms 348 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
4 Halted 0 ms 0 KB -