#include <bits/stdc++.h>
#include "train.h"
using namespace std;
vector<int>who_wins(vector<int>a, vector<int>r, vector<int>u, vector<int>v) {
int n = r.size();
int m = u.size();
vector<bool>self(n,0);
vector<bool>nx(n,0);
for(int i = 0 ; i < m ; i++) {
if(v[i] == u[i])
self[v[i]] = 1;
else
nx[u[i]] = 1;
}
vector<int>ans(n,0);
for(int i = n-1 ; i >= 0 ; i--) {
if(a[i]) {
if(nx[i] && ans[i+1])
ans[i] = 1;
if(self[i] && r[i])
ans[i] = 1;
} else {
if(nx[i] && ans[i+1]) {
if(!self[i])
ans[i] = 1;
if(self[i] && r[i])
ans[i] = 1;
} else {
if(!nx[i] && r[i])
ans[i] = 1;
}
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
468 KB |
Output is correct |
2 |
Correct |
3 ms |
564 KB |
Output is correct |
3 |
Correct |
3 ms |
580 KB |
Output is correct |
4 |
Correct |
3 ms |
564 KB |
Output is correct |
5 |
Correct |
3 ms |
468 KB |
Output is correct |
6 |
Correct |
3 ms |
468 KB |
Output is correct |
7 |
Correct |
3 ms |
468 KB |
Output is correct |
8 |
Correct |
3 ms |
568 KB |
Output is correct |
9 |
Correct |
3 ms |
468 KB |
Output is correct |
10 |
Correct |
3 ms |
564 KB |
Output is correct |
11 |
Correct |
3 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
596 KB |
Output is correct |
2 |
Correct |
6 ms |
724 KB |
Output is correct |
3 |
Correct |
6 ms |
724 KB |
Output is correct |
4 |
Incorrect |
5 ms |
792 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 |
5 ms |
596 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 |
Incorrect |
5 ms |
608 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 |
5 ms |
468 KB |
Output is correct |
2 |
Correct |
3 ms |
564 KB |
Output is correct |
3 |
Correct |
3 ms |
580 KB |
Output is correct |
4 |
Correct |
3 ms |
564 KB |
Output is correct |
5 |
Correct |
3 ms |
468 KB |
Output is correct |
6 |
Correct |
3 ms |
468 KB |
Output is correct |
7 |
Correct |
3 ms |
468 KB |
Output is correct |
8 |
Correct |
3 ms |
568 KB |
Output is correct |
9 |
Correct |
3 ms |
468 KB |
Output is correct |
10 |
Correct |
3 ms |
564 KB |
Output is correct |
11 |
Correct |
3 ms |
468 KB |
Output is correct |
12 |
Incorrect |
0 ms |
212 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
13 |
Halted |
0 ms |
0 KB |
- |