#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] = ((bool)a[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 |
Correct |
421 ms |
1416 KB |
Output is correct |
2 |
Correct |
130 ms |
1208 KB |
Output is correct |
3 |
Correct |
62 ms |
1004 KB |
Output is correct |
4 |
Correct |
26 ms |
852 KB |
Output is correct |
5 |
Correct |
14 ms |
852 KB |
Output is correct |
6 |
Correct |
10 ms |
724 KB |
Output is correct |
7 |
Correct |
16 ms |
824 KB |
Output is correct |
8 |
Correct |
11 ms |
824 KB |
Output is correct |
9 |
Correct |
9 ms |
824 KB |
Output is correct |
10 |
Correct |
8 ms |
824 KB |
Output is correct |
11 |
Correct |
7 ms |
736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
141 ms |
284 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
5 ms |
296 KB |
Output is correct |
9 |
Correct |
51 ms |
300 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
26 ms |
296 KB |
Output is correct |
12 |
Correct |
1 ms |
296 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2095 ms |
1180 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2049 ms |
1288 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2059 ms |
1388 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
421 ms |
1416 KB |
Output is correct |
2 |
Correct |
130 ms |
1208 KB |
Output is correct |
3 |
Correct |
62 ms |
1004 KB |
Output is correct |
4 |
Correct |
26 ms |
852 KB |
Output is correct |
5 |
Correct |
14 ms |
852 KB |
Output is correct |
6 |
Correct |
10 ms |
724 KB |
Output is correct |
7 |
Correct |
16 ms |
824 KB |
Output is correct |
8 |
Correct |
11 ms |
824 KB |
Output is correct |
9 |
Correct |
9 ms |
824 KB |
Output is correct |
10 |
Correct |
8 ms |
824 KB |
Output is correct |
11 |
Correct |
7 ms |
736 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
141 ms |
284 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
5 ms |
296 KB |
Output is correct |
20 |
Correct |
51 ms |
300 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
26 ms |
296 KB |
Output is correct |
23 |
Correct |
1 ms |
296 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
1 ms |
212 KB |
Output is correct |
27 |
Correct |
1 ms |
212 KB |
Output is correct |
28 |
Correct |
1 ms |
212 KB |
Output is correct |
29 |
Correct |
0 ms |
212 KB |
Output is correct |
30 |
Correct |
1 ms |
212 KB |
Output is correct |
31 |
Correct |
1 ms |
212 KB |
Output is correct |
32 |
Execution timed out |
2095 ms |
1180 KB |
Time limit exceeded |
33 |
Halted |
0 ms |
0 KB |
- |