Submission #429164

# Submission time Handle Problem Language Result Execution time Memory
429164 2021-06-15T18:00:28 Z vanic Ancient Books (IOI17_books) C++14
0 / 100
289 ms 332 KB
#include "books.h"
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;

const int inf=100;

int n;
const int cap=10;

int rek(int x, int d, int t, vector < int > l){
	if(d>cap || x>=n || x<0){
		return inf;
	}
	if(!x){
		bool p=1;
		for(int i=0; i<n; i++){
			if(l[i]!=i){
				p=0;
				break;
			}
		}
		if(p){
			return d;
		}
	}
	int mini=inf;
	mini=min(mini, rek(x+1, d+1, t, l));
	mini=min(mini, rek(x-1, d+1, t, l));
	swap(l[x], t);
	mini=min(mini, rek(x+1, d+1, t, l));
	mini=min(mini, rek(x-1, d+1, t, l));
	return mini;
}


ll minimum_walk(vector < int > p, int s) {
	n=p.size();
	return rek(0, 0, -1, p);
}
# Verdict Execution time Memory Grader output
1 Correct 17 ms 204 KB Output is correct
2 Correct 23 ms 204 KB Output is correct
3 Incorrect 18 ms 284 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 17 ms 204 KB Output is correct
2 Correct 23 ms 204 KB Output is correct
3 Incorrect 18 ms 284 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 17 ms 204 KB Output is correct
2 Correct 23 ms 204 KB Output is correct
3 Incorrect 18 ms 284 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 Incorrect 289 ms 332 KB 3rd lines differ - on the 1st token, expected: '3304', found: '100'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 17 ms 204 KB Output is correct
2 Correct 23 ms 204 KB Output is correct
3 Incorrect 18 ms 284 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
4 Halted 0 ms 0 KB -