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 "train.h"
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include <cassert>
#define ll long long
#define MX 5050
using namespace std;
int n,m,a[MX],c[MX],to[MX],toc[MX];
// void addl(int x,int y)
// {
// e[++tot].to=y;
// e[tot].nx=h[x];
// h[x]=tot;
// return;
// }
int dfs(int x)
{
if(c[x]==0&&a[x]==0&&toc[x]==1)return 0;
if(c[x]==1&&a[x]==1&&toc[x]==1)return 1;
if(to[x])return dfs(x+1);
else if(c[x]==0)return 0;
else return 1;
}
std::vector<int> who_wins(std::vector<int> A, std::vector<int> C, std::vector<int> U, std::vector<int> V) {
std::vector<int> ans(A.size());
n=A.size();
m=U.size();
for(int i=1;i<=n;++i){
a[i]=A[i-1];
c[i]=C[i-1];
}
for(int i=0;i<m;++i){
if(U[i]==V[i])toc[U[i]+1]=1;
else to[U[i]+1]=1;
}
// addl(U[i]+1,V[i]+1);
for(int i=1;i<=n;++i)
ans[i-1]=dfs(i);
return ans;
}
# | 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... |