#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;
vector<int>R;
bool dfs(int u) {
if(u == t && f)
return 1;
f = 1;
if(vis[u] || R[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) {
R = r;
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];
}
vector<int>ans(n);
for(int i = 0 ; i < n ; i++)
ans[i] = 1 - pos[i];
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
66 ms |
812 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
199 ms |
1172 KB |
Output is correct |
2 |
Correct |
190 ms |
1124 KB |
Output is correct |
3 |
Correct |
154 ms |
1084 KB |
Output is correct |
4 |
Incorrect |
504 ms |
1092 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
192 ms |
920 KB |
Output is correct |
2 |
Correct |
300 ms |
1156 KB |
Output is correct |
3 |
Correct |
389 ms |
1248 KB |
Output is correct |
4 |
Correct |
243 ms |
1236 KB |
Output is correct |
5 |
Correct |
536 ms |
1248 KB |
Output is correct |
6 |
Correct |
459 ms |
1240 KB |
Output is correct |
7 |
Correct |
479 ms |
1236 KB |
Output is correct |
8 |
Correct |
337 ms |
1204 KB |
Output is correct |
9 |
Correct |
230 ms |
1156 KB |
Output is correct |
10 |
Correct |
217 ms |
1252 KB |
Output is correct |
11 |
Correct |
220 ms |
1252 KB |
Output is correct |
12 |
Correct |
237 ms |
1280 KB |
Output is correct |
13 |
Correct |
480 ms |
1292 KB |
Output is correct |
14 |
Correct |
395 ms |
1192 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
600 ms |
1116 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
66 ms |
812 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |