Submission #1062406

# Submission time Handle Problem Language Result Execution time Memory
1062406 2024-08-17T06:16:33 Z Faisal_Saqib Ancient Books (IOI17_books) C++17
0 / 100
2000 ms 604 KB
#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>20 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);
    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 time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 96 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 2 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 96 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 2 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 96 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 2049 ms 604 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 96 ms 348 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
4 Halted 0 ms 0 KB -