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;
void dfs(int v, vector<int>& x, vector<int>& c, vector<vector<int>>& adj, vector<int>& res){
if (x[v]) res[v]=1;
cerr << "vertex " << v << '\n';
if(res[v]){
for(int u: adj[v]){
cerr << "n " << u << '\n';
if (u==v) continue;
c[u]--;
if(c[u]==0 && !res[u]) {
res[u]=1;
dfs(u,x,c,adj,res);
}
}
}
}
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
int n = a.size();
int m = u.size();
vector<int> res(n,1);
vector<int> loop(n,0);
//add the edges to adj in the opposite direction
for(int i=0;i<m;++i){
if(u[i]==v[i]) loop[u[i]]=1;
}
int last = 0;
int curr = 0;
while(curr < n){
if(loop[curr] && r[curr]==a[curr]) {
for(int i=last;i<=curr;++i){
res[i] = a[curr];
}
last = curr+1;
}
++curr;
}
for(int i=last;i<curr;++i){
res[i] = a[curr];
}
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... |