# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
138236 | rajarshi_basu | Toy Train (IOI17_train) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i = a;i<=b;i++)
#define ll long long int
#define pb push_back
#define vi vector<int>
#define ff first
#define ss second
#define vv vector
#define ii pair<int,int>
using namespace std;
const int MAXN = 5001;
bool self[MAXN];
bool nxt[MAXN];
int* who_wins(vi a,vi r,vi u,vi v){
int m = u.length();
int n = a.length();
FOR(i,m){
if(u[i] == v[i])self[u[i]] = 1;
else nxt[u[i]] = 1;
}
int arr[n];
for(int i = n-1;i >= 0;i--){
if(a[i] == 0 and r[i] == 0){
if(self[i])arr[i] = 0;
else arr[i] = arr[i+1];
}else if(a[i] == 0 and r[i] == 1){
if(nxt[i])arr[i] = arr[i+1];
else arr[i] = 1;
}else if(a[i] == 1 and r[i] == 0){
if(nxt[i])arr[i] = arr[i+1];
else arr[i] = 0;
}else{
if(self[i])arr[i] = 1;
else arr[i] = arr[i+1];
}
}
return arr;
}