#include <bits/stdc++.h>
#include "train.h"
using namespace std;
typedef long long ll;
vector<vector<ll>> adj;
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
ll n = a.size(), m = u.size();
vector<int> res(n);
adj = vector<vector<ll>>(n);
for (int i = 0; i < m; i++) {
adj[u[i]].push_back(v[i]);
}
for (int i = n-1; i >= 0; i--) {
bool win = false;
if (a[i]) {
for (auto &e : adj[i]) {
if (e != i && res[e]) win = true;
if (e == i && r[i]) win = true;
}
res[i] = win;
}
else {
for (auto &e : adj[i]) {
if (e != i && !res[e]) win = true;
if (e == i && !r[i]) win = true;
}
res[i] = !win;
}
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
860 KB |
Output is correct |
2 |
Correct |
3 ms |
856 KB |
Output is correct |
3 |
Correct |
2 ms |
860 KB |
Output is correct |
4 |
Correct |
4 ms |
960 KB |
Output is correct |
5 |
Correct |
4 ms |
1116 KB |
Output is correct |
6 |
Correct |
2 ms |
860 KB |
Output is correct |
7 |
Correct |
2 ms |
860 KB |
Output is correct |
8 |
Correct |
2 ms |
856 KB |
Output is correct |
9 |
Correct |
2 ms |
860 KB |
Output is correct |
10 |
Correct |
2 ms |
860 KB |
Output is correct |
11 |
Correct |
2 ms |
860 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
1372 KB |
Output is correct |
2 |
Correct |
4 ms |
1368 KB |
Output is correct |
3 |
Correct |
4 ms |
1252 KB |
Output is correct |
4 |
Incorrect |
5 ms |
1368 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
1116 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
1372 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
860 KB |
Output is correct |
2 |
Correct |
3 ms |
856 KB |
Output is correct |
3 |
Correct |
2 ms |
860 KB |
Output is correct |
4 |
Correct |
4 ms |
960 KB |
Output is correct |
5 |
Correct |
4 ms |
1116 KB |
Output is correct |
6 |
Correct |
2 ms |
860 KB |
Output is correct |
7 |
Correct |
2 ms |
860 KB |
Output is correct |
8 |
Correct |
2 ms |
856 KB |
Output is correct |
9 |
Correct |
2 ms |
860 KB |
Output is correct |
10 |
Correct |
2 ms |
860 KB |
Output is correct |
11 |
Correct |
2 ms |
860 KB |
Output is correct |
12 |
Incorrect |
0 ms |
348 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
13 |
Halted |
0 ms |
0 KB |
- |