#include "train.h"
#include <bits/stdc++.h>
#define N 5005
using namespace std;
int path[N][N];
bool edge[N][N];
int path2[N][N];
bool special[N];
vector<int> adj[N];
vector<int> adj2[N];
void dfs(int v,int num){
path[num][v] = 1;
for(auto u:adj[v]){
if(!path[num][u]){
dfs(u,num);
}
}
}
void dfs2(int v,int num){
path2[num][v] = 1;
for(auto u:adj2[v]){
if(!path2[num][u]){
dfs2(u,num);
}
}
}
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
int n = a.size();
int m = u.size();
for(int i=0;i<m;i++){
edge[u[i]][v[i]] = 1;
adj[u[i]].push_back(v[i]);
}
for(int i = 0;i<n;i++){
dfs(i,i);
}
vector<int> res(n);
for(int i = 0; i < n; i++){
int num = i;
while(1){
if(a[num]){
if(edge[num][num] && r[num]){
res[i] = 1;
break;
}
if(!edge[num][num+1]){
res[i] = 0;
break;
}
num = num+1;
}
else{
if(edge[num][num] && !r[num]){
res[i] = 0;
break;
}
if(!edge[num][num+1]){
res[i] = 1;
break;
}
num = num+1;
}
}
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
199 ms |
87980 KB |
Output is correct |
2 |
Correct |
86 ms |
59980 KB |
Output is correct |
3 |
Correct |
52 ms |
50000 KB |
Output is correct |
4 |
Correct |
29 ms |
43980 KB |
Output is correct |
5 |
Correct |
21 ms |
42292 KB |
Output is correct |
6 |
Correct |
18 ms |
41556 KB |
Output is correct |
7 |
Correct |
19 ms |
41420 KB |
Output is correct |
8 |
Correct |
19 ms |
41448 KB |
Output is correct |
9 |
Correct |
19 ms |
41188 KB |
Output is correct |
10 |
Correct |
19 ms |
41228 KB |
Output is correct |
11 |
Correct |
17 ms |
41172 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
596 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 |
184 ms |
118268 KB |
Output is correct |
2 |
Correct |
176 ms |
119284 KB |
Output is correct |
3 |
Correct |
175 ms |
120220 KB |
Output is correct |
4 |
Incorrect |
932 ms |
123244 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 |
740 ms |
122148 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 |
943 ms |
122920 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 |
199 ms |
87980 KB |
Output is correct |
2 |
Correct |
86 ms |
59980 KB |
Output is correct |
3 |
Correct |
52 ms |
50000 KB |
Output is correct |
4 |
Correct |
29 ms |
43980 KB |
Output is correct |
5 |
Correct |
21 ms |
42292 KB |
Output is correct |
6 |
Correct |
18 ms |
41556 KB |
Output is correct |
7 |
Correct |
19 ms |
41420 KB |
Output is correct |
8 |
Correct |
19 ms |
41448 KB |
Output is correct |
9 |
Correct |
19 ms |
41188 KB |
Output is correct |
10 |
Correct |
19 ms |
41228 KB |
Output is correct |
11 |
Correct |
17 ms |
41172 KB |
Output is correct |
12 |
Incorrect |
1 ms |
596 KB |
3rd lines differ - on the 8th token, expected: '0', found: '1' |
13 |
Halted |
0 ms |
0 KB |
- |