#include "train.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int inf = 5e3+9;
int n,m;
vector<int> adj[inf];
bool vis[inf],station[inf];
bool incycle(int u,int goal){
bool ret = 0;
vis[u] = 1;
for(auto v:adj[u]){
if(v == goal)
return ret = 1;
if(!vis[v])
ret |= incycle(v,goal);
}
return ret;
}
bool findstation(int u){
bool ret = 0;
if(station[u])
return ret = 1;
vis[u] = 1;
for(auto v:adj[u])
if(!vis[v])
ret |= findstation(v);
return ret;
}
vector<int> who_wins(vector<int> a, vector<int> R, vector<int> U, vector<int> V) {
vector<int> ret;
n = a.size();m = U.size();
for(int i=0;i<m;i++)
adj[U[i]].pb(V[i]);
for(int i=0;i<n;i++){
station[i] = R[i] && incycle(i,i);
memset(vis,0,sizeof(vis));
}
for(int i=0;i<n;i++){
ret.pb(findstation(i));
memset(vis,0,sizeof(vis));
}
return ret;
}
/*
2 4
0 0
1 0
0 1
1 0
1 1
0 0
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
94 ms |
1092 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 |
Incorrect |
1 ms |
332 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 |
192 ms |
1468 KB |
Output is correct |
2 |
Correct |
165 ms |
1448 KB |
Output is correct |
3 |
Correct |
192 ms |
1488 KB |
Output is correct |
4 |
Correct |
971 ms |
1400 KB |
Output is correct |
5 |
Correct |
826 ms |
1316 KB |
Output is correct |
6 |
Correct |
561 ms |
1376 KB |
Output is correct |
7 |
Correct |
256 ms |
1220 KB |
Output is correct |
8 |
Correct |
284 ms |
1248 KB |
Output is correct |
9 |
Correct |
258 ms |
1220 KB |
Output is correct |
10 |
Correct |
347 ms |
1200 KB |
Output is correct |
11 |
Correct |
306 ms |
1180 KB |
Output is correct |
12 |
Correct |
27 ms |
1168 KB |
Output is correct |
13 |
Correct |
1053 ms |
1420 KB |
Output is correct |
14 |
Correct |
984 ms |
1416 KB |
Output is correct |
15 |
Correct |
1125 ms |
1372 KB |
Output is correct |
16 |
Correct |
991 ms |
1392 KB |
Output is correct |
17 |
Correct |
974 ms |
1368 KB |
Output is correct |
18 |
Correct |
436 ms |
1056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
769 ms |
1136 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 |
981 ms |
1332 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 |
Incorrect |
94 ms |
1092 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |