#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
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 |
1 |
Incorrect |
385 ms |
1492 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2064 ms |
1372 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2068 ms |
1468 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2080 ms |
1620 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
385 ms |
1492 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |