#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[i], set, a, r, g))
can = true;
} else if (!bk(ot, d + 1, (r[i] ? d : lp), a[i], 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++) {
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
353 ms |
1364 KB |
3rd lines differ - on the 3rd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2081 ms |
1108 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2079 ms |
1236 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2074 ms |
1440 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
353 ms |
1364 KB |
3rd lines differ - on the 3rd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |