This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/******************************************************************************
                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N = 1e5 + 10;
vector<ll> as,ap,aw,al;
int solve(int x,int z){
    // cout<<z<<" ";
    if(x==N) return z;
    if(as[x]<=z){
        int nz = z+as[x];
        return solve(aw[x],nz);
    }else{
        int nz = z+ap[x];
        return solve(al[x],nz);
    }
}
int64_t simulate(int x,int z){
    int ans = solve(x,z);
    return ans;
}
void init(int n,vector<int> s,vector<int> p,vector<int> w,vector<int> l){
    N = n;
    for(auto z:s){
        as.push_back(z);
    }
    for(auto z:p){
        ap.push_back(z);
    }
    for(auto z:w){
        aw.push_back(z);
    }
    for(auto z:l){
        al.push_back(z);
    }
}
// int main()
// {
//     init(3, {2, 6, 9}, {3, 1, 2}, {2, 2, 3}, {1, 0, 1});
//     cout<<simulate(2, 3)<<endl;
    
//     return 0;
// }
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |