#include "train.h"
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sep ' '
#define debug(x) cerr << #x << ": " << x << endl;
const int MAXN = 1e6 + 10;
int n, m;
bool A[MAXN], R[MAXN];
vector<int> adj[MAXN];
bool W[MAXN];
vector<int> who_wins(vector<int> a_, vector<int> r_, vector<int> u_, vector<int> v_) {
n = a_.size();
for (int i = 0; i < n; i++)
A[i] = a_[i], R[i] = r_[i];
m = u_.size();
for (int i = 0; i < m; i++)
adj[u_[i]].push_back(v_[i]);
for (int i = n - 1; i >= 0; i--) {
bool f1 = (find(all(adj[i]), i + 1) != adj[i].end());
bool f2 = (find(all(adj[i]), i) != adj[i].end());
if (A[i]) {
if (R[i]) {
if (f2) W[i] = 1;
else W[i] = W[i + 1];
} else {
if (f1) W[i] = W[i + 1];
else W[i] = 0;
}
} else {
if (R[i]) {
if (f1) W[i] = W[i + 1];
else W[i] = 1;
} else {
if (f2) W[i] = 0;
else W[i] = W[i + 1];
}
}
}
vector<int> res;
for (int i = 0; i < n; i++)
res.push_back(W[i]);
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
24276 KB |
Output is correct |
2 |
Correct |
13 ms |
24216 KB |
Output is correct |
3 |
Correct |
14 ms |
24140 KB |
Output is correct |
4 |
Correct |
13 ms |
24104 KB |
Output is correct |
5 |
Correct |
14 ms |
24148 KB |
Output is correct |
6 |
Correct |
13 ms |
24184 KB |
Output is correct |
7 |
Correct |
13 ms |
24148 KB |
Output is correct |
8 |
Correct |
14 ms |
24208 KB |
Output is correct |
9 |
Correct |
14 ms |
24132 KB |
Output is correct |
10 |
Correct |
13 ms |
24148 KB |
Output is correct |
11 |
Correct |
13 ms |
24128 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
23764 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 |
Correct |
14 ms |
24444 KB |
Output is correct |
2 |
Correct |
14 ms |
24404 KB |
Output is correct |
3 |
Correct |
14 ms |
24380 KB |
Output is correct |
4 |
Incorrect |
16 ms |
24532 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
24276 KB |
3rd lines differ - on the 696th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
15 ms |
24404 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
24276 KB |
Output is correct |
2 |
Correct |
13 ms |
24216 KB |
Output is correct |
3 |
Correct |
14 ms |
24140 KB |
Output is correct |
4 |
Correct |
13 ms |
24104 KB |
Output is correct |
5 |
Correct |
14 ms |
24148 KB |
Output is correct |
6 |
Correct |
13 ms |
24184 KB |
Output is correct |
7 |
Correct |
13 ms |
24148 KB |
Output is correct |
8 |
Correct |
14 ms |
24208 KB |
Output is correct |
9 |
Correct |
14 ms |
24132 KB |
Output is correct |
10 |
Correct |
13 ms |
24148 KB |
Output is correct |
11 |
Correct |
13 ms |
24128 KB |
Output is correct |
12 |
Incorrect |
10 ms |
23764 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
13 |
Halted |
0 ms |
0 KB |
- |