#include <bits/stdc++.h>
#include "train.h"
//#include "grader.cpp"
using namespace std ;
const int MAX = 5010 ;
int A[MAX] , R[MAX] ;
vector< vector<int> >adj(MAX) ;
int n , m ;
int vis[MAX] , mark[MAX] , Ans[MAX] ;
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v)
{
n = a.size() ;
m = u.size() ;
for(int i = 0 ; i < m ; ++i)
adj[u[i]].push_back(v[i]) ;
vector<int>ans ;
for(int i = n-1 ; i >= 0 ; --i)
{
A[i] = a[i] , R[i] = r[i] ;
Ans[i] = 0 ;
for(auto &child : adj[i])
{
if(child == i)
{
if(R[i] == A[i])
Ans[i] = 1 ;
}
else if(child == i+1)
{
if(A[i] && A[i+1] == Ans[i+1])
Ans[i] = 1 ;
if(!A[i] && A[i+1] != Ans[i+1])
Ans[i] = 1 ;
}
}
}
for(int i = 0 ; i < n ; ++i)
ans.push_back(Ans[i] == A[i]) ;
return ans ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
896 KB |
Output is correct |
2 |
Correct |
5 ms |
1024 KB |
Output is correct |
3 |
Correct |
4 ms |
1024 KB |
Output is correct |
4 |
Correct |
5 ms |
1024 KB |
Output is correct |
5 |
Correct |
5 ms |
1024 KB |
Output is correct |
6 |
Correct |
4 ms |
1024 KB |
Output is correct |
7 |
Correct |
5 ms |
1024 KB |
Output is correct |
8 |
Correct |
4 ms |
1024 KB |
Output is correct |
9 |
Correct |
4 ms |
1024 KB |
Output is correct |
10 |
Correct |
6 ms |
1152 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 8th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
1152 KB |
Output is correct |
2 |
Correct |
8 ms |
1408 KB |
Output is correct |
3 |
Correct |
8 ms |
1408 KB |
Output is correct |
4 |
Incorrect |
9 ms |
1408 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 |
1024 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 |
8 ms |
1152 KB |
3rd lines differ - on the 2nd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
896 KB |
Output is correct |
2 |
Correct |
5 ms |
1024 KB |
Output is correct |
3 |
Correct |
4 ms |
1024 KB |
Output is correct |
4 |
Correct |
5 ms |
1024 KB |
Output is correct |
5 |
Correct |
5 ms |
1024 KB |
Output is correct |
6 |
Correct |
4 ms |
1024 KB |
Output is correct |
7 |
Correct |
5 ms |
1024 KB |
Output is correct |
8 |
Correct |
4 ms |
1024 KB |
Output is correct |
9 |
Correct |
4 ms |
1024 KB |
Output is correct |
10 |
Correct |
6 ms |
1152 KB |
Output is correct |
11 |
Correct |
4 ms |
896 KB |
Output is correct |
12 |
Incorrect |
1 ms |
384 KB |
3rd lines differ - on the 8th token, expected: '0', found: '1' |
13 |
Halted |
0 ms |
0 KB |
- |