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 <bits/stdc++.h>
using namespace std;
#include "train.h"
#define fin(i,s,n) for(auto i = s; i < n; ++i)
#define fine(i,s,n) for(auto i = s; i <= n; ++i)
#define pb push_back
#define eb emplace_back
#define x first
#define y second
#define all(x) (x).begin(),(x).end()
#define chkmin(a,b) a = min(a,b)
#define chkmax(a,b) a = max(a,b)
using stdvec = vector<int>;
using ii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vii = vector<ii>;
#define sz(a) int((a).size())
const int maxn = 5005;
vi g[maxn];
int vis[maxn];
bool p[maxn], c[maxn];
bool dfs(int u) {
if(vis[u]) return 0;
if(c[u]) return 1;
vis[u] = 1;
for(int v : g[u]) if(dfs(v)) return 1;
return 0;
}
vi who_wins(vi a, vi r, vi u, vi v) {
int n = a.size(),m = u.size();
fin(i,0,m) g[u[i]].pb(v[i]);
fin(i,0,n) p[i] = a[i], c[i] = r[i];
vi res(n);
fin(i,0,n) {
fin(j,0,n) vis[j] = 0;
res[i] = dfs(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... |