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 int long long
typedef vector<int> vi;
typedef vector<vi> vii;
bool bk(int i, int d, int lp, bool obj, vi& set, vector<signed>& a, vector<signed>& r, vii& g)
{
if (set[i] != -1) {
if (set[i] <= lp)
return obj;
else
return !obj;
}
set[i] = d;
bool can = false;
for (int ot : g[i]) {
if (a[i] == a[ot]) {
if (bk(ot, d + 1, (r[i] ? d : lp), a[ot], set, a, r, g))
can = true;
} else if (!bk(ot, d + 1, (r[i] ? d : lp), a[ot], set, a, r, g))
can = true;
}
set[i] = -1;
return can;
}
vector<signed> who_wins(vector<signed> a, vector<signed> r, vector<signed> u, vector<signed> v)
{
vector<signed> res(a.size(), 0);
vii g(a.size());
for (int i = 0; i < u.size(); i++)
g[u[i]].push_back(v[i]);
for (int i = 0; i < a.size(); i++) {
vi set(a.size(), -1);
res[i] = bk(i, 0, -1, a[i], set, a, r, g);
}
return res;
}
Compilation message (stderr)
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:36:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | for (int i = 0; i < u.size(); i++)
| ~~^~~~~~~~~~
train.cpp:38:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
38 | for (int i = 0; i < a.size(); i++) {
| ~~^~~~~~~~~~
# | 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... |