// Subtask 4
#include "train.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5000 + 10;
int n, m;
vector<int> g[maxn], r;
bool visited[maxn];
void dfs(int v){
visited[v] = 1;
for (auto u : g[v])
if (!visited[u] and r[u] == 0)
dfs(u);
}
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
n = a.size(), m = u.size();
::r = r;
for (int i = 0; i < m; i++)
g[v[i]].push_back(u[i]);
vector<int> dp(n);
for (int i = 0; i < n; i++){
dp[i] = 1;
if (r[i] == 0){
memset(visited, 0, sizeof visited);
dfs(i);
for (int j = 0; j < m; j++)
if (visited[v[j]] and u[j] == i)
dp[i] = 0;
}
}
for (int t = 0; t < n; t++)
for (int i = 0; i < m; i++)
dp[u[i]] &= dp[v[i]];
return dp;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
128 ms |
768 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
608 ms |
1252 KB |
Output is correct |
2 |
Correct |
527 ms |
1272 KB |
Output is correct |
3 |
Correct |
458 ms |
1148 KB |
Output is correct |
4 |
Incorrect |
1403 ms |
1272 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
277 ms |
996 KB |
Output is correct |
2 |
Correct |
555 ms |
1272 KB |
Output is correct |
3 |
Correct |
699 ms |
1400 KB |
Output is correct |
4 |
Correct |
494 ms |
1400 KB |
Output is correct |
5 |
Correct |
909 ms |
1400 KB |
Output is correct |
6 |
Correct |
891 ms |
1400 KB |
Output is correct |
7 |
Correct |
829 ms |
1400 KB |
Output is correct |
8 |
Correct |
606 ms |
1276 KB |
Output is correct |
9 |
Correct |
321 ms |
1272 KB |
Output is correct |
10 |
Correct |
391 ms |
1332 KB |
Output is correct |
11 |
Correct |
370 ms |
1376 KB |
Output is correct |
12 |
Correct |
394 ms |
1336 KB |
Output is correct |
13 |
Correct |
1398 ms |
1372 KB |
Output is correct |
14 |
Correct |
872 ms |
1272 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1518 ms |
1188 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
128 ms |
768 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |