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;
const int N = 2e3+10;
vector<int>adj[N],R,A;
set<int>st;
int cnt[N];
int n,m;
bool vis[N];
bool dfs(int i,int pre){
if(vis[i])
return 0;
st.insert(i);
vis[i] = 1;
cnt[i] += cnt[pre]+R[i];
bool ret = 0;
for(auto x:adj[i]){
ret |= dfs(x,i);
if(st.find(x)==st.end())
continue;
if(cnt[i]-cnt[x]+R[x]>0)ret = 1;
}
st.erase(i);
return ret;
}
vector<int>ans;
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
n = a.size(),m = u.size();
A = a;R = r;
for(int i=0;i<m;i++)
adj[u[i]].push_back(v[i]);
for(int i=0;i<n;i++){
ans.push_back(dfs(i,n+1));
memset(vis,0,sizeof(vis));
memset(cnt,0,sizeof(cnt));
}
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... |