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>
using namespace std;
int n, m;
vector<int> aa, rr;
int solve(vector<int> adj[], int pos, int cur)
{
int csz = adj[pos].size();
int nxt;
if(csz == 1)
{
if(adj[pos][0] == pos)
return rr[adj[pos][0]];
else
nxt = adj[pos][0];
}
else
{
if(rr[pos])
{
if(aa[pos])
return 1;
else
nxt = max(adj[pos][0], adj[pos][1]);
}
else
{
if(!aa[pos])
return 0;
else
nxt = max(adj[pos][0], adj[pos][1]);
}
}
return solve(adj, nxt, cur + 1);
}
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
n = a.size(), m = u.size();
aa = a;
rr = r;
vector<int> adj[n], ans(n);
for(int i=0;i<m;i++)
adj[u[i]].push_back(v[i]);
for(int i=0;i<n;i++)
{
ans[i] = solve(adj, i, 0);
}
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... |