#include <bits/stdc++.h>
#include "train.h"
using namespace std;
const int MAX_N = 5005;
const int MAX_M = 20005;
int N, M;
vector <int> graph[MAX_N];
int A[MAX_N], R[MAX_N];
bool visited[MAX_N];
bool dfs(int u, int x, bool found, bool init = false) {
// cout << x << " : " << u << ' ' << found << endl;
if (u == x and init == true) return found;
if (visited[u] == true) return false;
init = true;
visited[u] = true;
if (R[u] == 1) found = true;
for (auto v : graph[u]) if (dfs(v, x, found, true) == true) return true;
return false;
}
vector <int> who_wins(vector <int> a, vector <int> r, vector <int> u, vector <int> v) {
N = a.size(), M = u.size();
for (int i = 0; i < N; i++) A[i] = a[i], R[i] = r[i];
for (int i = 0; i < M; i++) graph[u[i]].push_back(v[i]);
vector <int> ans;
for (int s = 0; s < N; s++) {
for (int i = 0; i < N; i++) visited[i] = false;
ans.push_back(dfs(s, s, false));
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
108 ms |
1028 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
3rd lines differ - on the 8th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
118 ms |
1308 KB |
Output is correct |
2 |
Correct |
118 ms |
1280 KB |
Output is correct |
3 |
Correct |
121 ms |
1344 KB |
Output is correct |
4 |
Incorrect |
310 ms |
1220 KB |
3rd lines differ - on the 13th token, expected: '1', found: '0' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
330 ms |
1056 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
398 ms |
1184 KB |
3rd lines differ - on the 6th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
108 ms |
1028 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |