#include <bits/stdc++.h>
#include "train.h"
template <class T>
using Vec = std::vector<T>;
Vec<int> who_wins(Vec<int> a, Vec<int> r, Vec<int> u, Vec<int> v) {
const int n = (int) a.size();
const int m = (int) u.size();
{
bool sub1 = true;
Vec<bool> loop(n);
Vec<bool> right(n);
for (int i = 0; i < m; ++i) {
if (u[i] == v[i]) {
loop[u[i]] = true;
}
else if (u[i] + 1 == v[i]) {
right[u[i]] = true;
}
else {
sub1 = false;
break;
}
}
if (sub1) {
Vec<int> ret(n);
for (int i = n - 1; i >= 0; --i) {
if (a[i]) {
ret[i] = 0;
if (r[i] && loop[i]) {
ret[i] = 1;
}
if (right[i] && ret[i + 1]) {
ret[i] = 1;
}
}
else {
ret[i] = 1;
if (!r[i] && loop[i]) {
ret[i] = 0;
}
if (right[i] && !ret[i + 1]) {
ret[i] = 0;
}
}
}
return ret;
}
}
return {};
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
620 KB |
Output is correct |
2 |
Correct |
4 ms |
620 KB |
Output is correct |
3 |
Correct |
6 ms |
620 KB |
Output is correct |
4 |
Correct |
4 ms |
620 KB |
Output is correct |
5 |
Correct |
4 ms |
620 KB |
Output is correct |
6 |
Correct |
4 ms |
620 KB |
Output is correct |
7 |
Correct |
4 ms |
620 KB |
Output is correct |
8 |
Correct |
4 ms |
620 KB |
Output is correct |
9 |
Correct |
4 ms |
640 KB |
Output is correct |
10 |
Correct |
4 ms |
620 KB |
Output is correct |
11 |
Correct |
3 ms |
620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
WA in grader: Wrong returned array size |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
768 KB |
WA in grader: Wrong returned array size |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
620 KB |
WA in grader: Wrong returned array size |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
768 KB |
WA in grader: Wrong returned array size |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
620 KB |
Output is correct |
2 |
Correct |
4 ms |
620 KB |
Output is correct |
3 |
Correct |
6 ms |
620 KB |
Output is correct |
4 |
Correct |
4 ms |
620 KB |
Output is correct |
5 |
Correct |
4 ms |
620 KB |
Output is correct |
6 |
Correct |
4 ms |
620 KB |
Output is correct |
7 |
Correct |
4 ms |
620 KB |
Output is correct |
8 |
Correct |
4 ms |
620 KB |
Output is correct |
9 |
Correct |
4 ms |
640 KB |
Output is correct |
10 |
Correct |
4 ms |
620 KB |
Output is correct |
11 |
Correct |
3 ms |
620 KB |
Output is correct |
12 |
Incorrect |
1 ms |
364 KB |
WA in grader: Wrong returned array size |
13 |
Halted |
0 ms |
0 KB |
- |