#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],charge[inf],NoStationCycle[inf];
bool incycle(int u,int goal){
bool ret = 0;
vis[u] = 1;
if(charge[u])
return 0;
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(NoStationCycle[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++)
charge[i] = R[i];
for(int i=0;i<n;i++){
memset(vis,0,sizeof(vis));
NoStationCycle[i] = incycle(i,i);
}
for(int i=0;i<n;i++){
memset(vis,0,sizeof(vis));
ret.pb(!findstation(i));
}
return ret;
}
/*
2 4
0 0
1 0
0 1
1 0
1 1
0 0
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
716 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
176 ms |
1244 KB |
Output is correct |
2 |
Correct |
56 ms |
1164 KB |
Output is correct |
3 |
Correct |
13 ms |
1060 KB |
Output is correct |
4 |
Incorrect |
592 ms |
1104 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
774 ms |
1092 KB |
Output is correct |
2 |
Correct |
233 ms |
1100 KB |
Output is correct |
3 |
Correct |
430 ms |
1280 KB |
Output is correct |
4 |
Correct |
368 ms |
1356 KB |
Output is correct |
5 |
Correct |
674 ms |
1256 KB |
Output is correct |
6 |
Correct |
539 ms |
1228 KB |
Output is correct |
7 |
Correct |
547 ms |
1248 KB |
Output is correct |
8 |
Correct |
386 ms |
1324 KB |
Output is correct |
9 |
Correct |
26 ms |
1100 KB |
Output is correct |
10 |
Correct |
1008 ms |
1548 KB |
Output is correct |
11 |
Correct |
942 ms |
1476 KB |
Output is correct |
12 |
Correct |
956 ms |
1436 KB |
Output is correct |
13 |
Correct |
558 ms |
1368 KB |
Output is correct |
14 |
Correct |
337 ms |
1280 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1125 ms |
1156 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
716 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |