#include "train.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 5000;
int n,m;
vector<int> adj[N];
bool sm[N],nxt[N];
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v)
{
n = a.size(),m = u.size();
for(int i = 0;i < m;i++)
{
adj[u[i]].push_back(v[i]);
if(u[i]==v[i]) sm[u[i]] = true;
else nxt[u[i]] = true;
}
vector<int> ans(n);
for(int i = n-1;i >= 0;i--)
{
if(!nxt[i] and !sm[i]){ ans[i] = 0; continue; }
if(a[i] and r[i] and sm[i]) ans[i] = 1;
else if(a[i])
{
if(nxt[i]) ans[i] = ans[i+1];
else ans[i] = 0;
}
else
{
if(!r[i] and sm[i]) ans[i] = 0;
else if(sm[i] and !nxt[i]) ans[i] = 1;
else if(!nxt[i]) ans[i] = 0;
else ans[i] = ans[i+1];
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
768 KB |
Output is correct |
2 |
Correct |
5 ms |
768 KB |
Output is correct |
3 |
Correct |
5 ms |
896 KB |
Output is correct |
4 |
Correct |
5 ms |
896 KB |
Output is correct |
5 |
Correct |
5 ms |
896 KB |
Output is correct |
6 |
Correct |
4 ms |
896 KB |
Output is correct |
7 |
Correct |
5 ms |
896 KB |
Output is correct |
8 |
Correct |
4 ms |
896 KB |
Output is correct |
9 |
Correct |
5 ms |
896 KB |
Output is correct |
10 |
Correct |
4 ms |
896 KB |
Output is correct |
11 |
Correct |
4 ms |
896 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 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 |
1056 KB |
Output is correct |
2 |
Correct |
8 ms |
1152 KB |
Output is correct |
3 |
Correct |
8 ms |
1024 KB |
Output is correct |
4 |
Incorrect |
9 ms |
1024 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 |
7 ms |
896 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 |
9 ms |
1024 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 |
768 KB |
Output is correct |
2 |
Correct |
5 ms |
768 KB |
Output is correct |
3 |
Correct |
5 ms |
896 KB |
Output is correct |
4 |
Correct |
5 ms |
896 KB |
Output is correct |
5 |
Correct |
5 ms |
896 KB |
Output is correct |
6 |
Correct |
4 ms |
896 KB |
Output is correct |
7 |
Correct |
5 ms |
896 KB |
Output is correct |
8 |
Correct |
4 ms |
896 KB |
Output is correct |
9 |
Correct |
5 ms |
896 KB |
Output is correct |
10 |
Correct |
4 ms |
896 KB |
Output is correct |
11 |
Correct |
4 ms |
896 KB |
Output is correct |
12 |
Incorrect |
1 ms |
384 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
13 |
Halted |
0 ms |
0 KB |
- |