제출 #1062408

#제출 시각아이디문제언어결과실행 시간메모리
1062408Faisal_Saqib고대 책들 (IOI17_books)C++17
12 / 100
2058 ms604 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define vll vector<ll> #define all(x) begin(x),end(x) #define pb push_back ll ans=1e9; void recur(ll i,ll n,vector<ll> p,ll hand,ll dist=0) { bool check=1; for(int j=0;j<n;j++) check&=(p[j]==j); if(check and dist<ans and i==0) ans=dist; if(dist>13 or dist>=ans)return; if(i<0 or n<=i)return; recur(i+1,n,p,hand,dist+1); recur(i-1,n,p,hand,dist+1); swap(p[i],hand); check=1; for(int j=0;j<n;j++) check&=(p[j]==j); if(check and dist<ans and i==0) ans=dist; recur(i+1,n,p,hand,dist+1); recur(i-1,n,p,hand,dist+1); } long long minimum_walk(std::vector<int> p, int s) { int n=p.size(); // Solve for s==0 ans=1e9; vll tp; for(auto j:p)tp.pb(j); recur(s,n,tp,-1); 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...