#include <bits/stdc++.h>
#include "train.h"
using namespace std;
const int mxN = (int)5005;
vector<int>adj[mxN];
vector<bool>vis;
int t;
bool f;
bool dfs(int u) {
if(u == t && f)
return 1;
f = 1;
if(vis[u])
return 0;
vis[u] = 1;
for(auto z : adj[u]) {
if(dfs(z))
return 1;
}
return 0;
}
vector<int>who_wins(vector<int>a, vector<int>r, vector<int>u, vector<int>v) {
int n = r.size();
int m = u.size();
for(int i = 0 ; i < m ; i++)
adj[u[i]].push_back(v[i]);
vector<int>pos(n,0);
for(int i = 0 ; i < n ; i++) {
if(r[i]) {
vis.clear();
vis.resize(n,0);
t = i;
f = 0;
pos[i] = dfs(i);
}
}
for(int x = 0 ; x < n ; x++)
for(int i = 0 ; i < n ; i++) {
for(auto z : adj[i])
pos[i] |= pos[z];
}
return pos;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
182 ms |
980 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
416 KB |
3rd lines differ - on the 8th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
167 ms |
1284 KB |
Output is correct |
2 |
Correct |
192 ms |
1236 KB |
Output is correct |
3 |
Correct |
195 ms |
1236 KB |
Output is correct |
4 |
Correct |
340 ms |
1320 KB |
Output is correct |
5 |
Correct |
235 ms |
1288 KB |
Output is correct |
6 |
Correct |
292 ms |
1240 KB |
Output is correct |
7 |
Correct |
392 ms |
1236 KB |
Output is correct |
8 |
Correct |
230 ms |
1236 KB |
Output is correct |
9 |
Correct |
219 ms |
1204 KB |
Output is correct |
10 |
Correct |
225 ms |
1228 KB |
Output is correct |
11 |
Correct |
233 ms |
1164 KB |
Output is correct |
12 |
Correct |
223 ms |
1072 KB |
Output is correct |
13 |
Correct |
223 ms |
1332 KB |
Output is correct |
14 |
Correct |
243 ms |
1332 KB |
Output is correct |
15 |
Correct |
225 ms |
1332 KB |
Output is correct |
16 |
Correct |
232 ms |
1356 KB |
Output is correct |
17 |
Correct |
219 ms |
1264 KB |
Output is correct |
18 |
Correct |
233 ms |
1040 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
491 ms |
1120 KB |
3rd lines differ - on the 696th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
240 ms |
1236 KB |
3rd lines differ - on the 2nd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
182 ms |
980 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |