Submission #429169

#TimeUsernameProblemLanguageResultExecution timeMemory
429169vanicAncient Books (IOI17_books)C++14
12 / 100
279 ms332 KiB
#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; if(l[0]!=0 && t){ p=0; } for(int i=1; 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...