Submission #428403

#TimeUsernameProblemLanguageResultExecution timeMemory
428403jeqchoAncient Books (IOI17_books)C++17
12 / 100
22 ms308 KiB
#include "books.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<pii> vpi; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define F0R(i,b) FOR(i,0,b) #define ROF(i,a,b) for(int i=(b)-1;i>=(a);--i) #define R0F(i,b) ROF(i,0,b) #define all(x) begin(x),end(x) #define pb push_back #define trav(a,x) for(auto&a:x) #define sz(x) int(x.size()) vi p; int n; ll ans=1e18; bool ok(int now) { if(now!=0)return 0; F0R(i,n) { if(p[i]!=i)return 0; } return 1; } void go(int now,int cur,ll d,int cnt) { if(now<0||now>=4)return; if(cnt>6)return; if(ok(now)) { ans=min(ans,d); } FOR(i,-4,4+1) { go(now+i,cur,d+abs(i),cnt+1); } swap(cur,p[now]); FOR(i,-4,4+1) { go(now+i,cur,d+abs(i),cnt+1); } swap(cur,p[now]); } ll minimum_walk(vi p1, int s) { n=sz(p1); p=p1; go(0,-1,0,0); return ans; }
#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...