Submission #757160

# Submission time Handle Problem Language Result Execution time Memory
757160 2023-06-12T17:57:39 Z alexander707070 Toy Train (IOI17_train) C++14
0 / 100
7 ms 3156 KB
#include<bits/stdc++.h>
#define MAXN 100007
using namespace std;
 
int n,m,curr,res[MAXN];
bool good[MAXN],special[MAXN],pr[MAXN],nxt[MAXN];
vector<int> v[MAXN],ans;

vector<int> who_wins(vector<int> A,vector<int> R, vector<int> from,vector<int> to){
    n=int(A.size()); m=int(from.size());
    
    for(int i=0;i<n;i++){
        if(A[i]==1)good[i]=true;
        if(R[i]==1)special[i]=true;
    }

    for(int i=0;i<m;i++){
        if(from[i]==to[i])pr[from[i]]=true;
        else nxt[i]=true;
    }

    if(special[n-1])curr=1;
    else curr=0;

    for(int i=n-1;i>=0;i--){
        if(pr[i]){
            if(good[i] and special[i])curr=1;
            else if(!good[i] and !special[i])curr=0;
        }
        res[i]=curr;

        if(i>0 and !nxt[i-1]){
            if(special[i-1])curr=1;
            else curr=0;
        }
    }

    for(int i=0;i<n;i++){
        ans.push_back(res[i]);
    }

    return ans;
}



# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2900 KB 3rd lines differ - on the 5th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2644 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 3156 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 3028 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 3104 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2900 KB 3rd lines differ - on the 5th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -