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;
#define sz(v) ((int)(v).size())
int n,m,ch[5005],is[2];
vector<int>G[5005],T;
void f(int p, vector<int> &a)
{
while(1)
{
T.clear();
for(int i=0;i<n;i++)
{
if(ch[i]!=p)
{
is[0]=is[1]=0;
for(auto &k:G[i])
{
if(ch[k]==p)is[p]=1;
else is[1-p]=1;
}
if((a[i]==p && is[a[i]]) || (a[i]!=p && !is[a[i]]))T.push_back(i);
}
}
if(!sz(T))break;
for(auto &k:T)ch[k]=p;
}
}
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
n=sz(a);m=sz(u);
vector<int> res(n);
for(int i=0;i<m;i++)G[u[i]].push_back(v[i]);
for(int i=0;i<n;i++)ch[i]=r[i];
f(1,a);
f(0,a);
for(int i=0;i<n;i++)res[i]=ch[i];
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... |