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 <bits/stdc++.h>
#define N 5005
using namespace std;
int path[N][N];
bool edge[N][N];
int path2[N][N];
bool special[N];
vector<int> adj[N];
vector<int> adj2[N];
void dfs(int v,int num){
path[num][v] = 1;
for(auto u:adj[v]){
if(!path[num][u]){
dfs(u,num);
}
}
}
void dfs2(int v,int num){
path2[num][v] = 1;
for(auto u:adj2[v]){
if(!path2[num][u]){
dfs2(u,num);
}
}
}
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
int n = a.size();
int m = u.size();
for(int i=0;i<m;i++){
edge[u[i]][v[i]] = 1;
adj[u[i]].push_back(v[i]);
}
for(int i = 0;i<n;i++){
dfs(i,i);
}
vector<int> res(n);
for(int i = 0; i < n; i++){
int num = i;
while(1){
if(a[num]){
if(edge[num][num] && r[num]){
res[i] = 1;
break;
}
if(!edge[num][num+1]){
res[i] = 0;
break;
}
num = num+1;
}
else{
if(edge[num][num] && !r[num]){
res[i] = 0;
break;
}
if(!edge[num][num+1]){
res[i] = 1;
break;
}
num = num+1;
}
}
}
return res;
}
# | 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... |