#include <bits/stdc++.h>
using namespace std;
const int N = 5000;
vector<int> to[N], from[N], a;
bool win[N], visited[N];
int degree[N], n, m;
void bfs() {
queue<int> que;
for (int i = 0; i < n; ++i) {
degree[i] = 0;
if (visited[i]) {
que.push(i);
}
}
while (!que.empty()) {
int u = que.front();
que.pop();
for (auto c : from[u]) {
if (!visited[c]) {
if (a[c] == 1 || ++degree[c] == (int) to[c].size()) {
visited[c] = true;
que.push(c);
}
}
}
}
}
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
n = a.size(), m = u.size(), ::a = a;
for (int i = 0; i < m; ++i) {
to[u[i]].push_back(v[i]);
from[v[i]].push_back(u[i]);
}
for (int i = 0; i < n; ++i) {
if (r[i] == 1) {
fill(visited, visited + n, false);
visited[i] = true;
bfs();
for (auto c : to[i]) {
win[i] |= visited[c];
}
}
}
copy(win, win + n, visited);
bfs();
return vector<int>(visited, visited + n);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
47 ms |
1224 KB |
3rd lines differ - on the 42nd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
460 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
56 ms |
1632 KB |
Output is correct |
2 |
Correct |
91 ms |
1612 KB |
Output is correct |
3 |
Correct |
106 ms |
1612 KB |
Output is correct |
4 |
Correct |
278 ms |
1740 KB |
Output is correct |
5 |
Correct |
58 ms |
1552 KB |
Output is correct |
6 |
Correct |
22 ms |
1612 KB |
Output is correct |
7 |
Correct |
289 ms |
1568 KB |
Output is correct |
8 |
Correct |
9 ms |
1612 KB |
Output is correct |
9 |
Correct |
11 ms |
1576 KB |
Output is correct |
10 |
Correct |
12 ms |
1484 KB |
Output is correct |
11 |
Correct |
8 ms |
1436 KB |
Output is correct |
12 |
Correct |
9 ms |
1484 KB |
Output is correct |
13 |
Correct |
13 ms |
1572 KB |
Output is correct |
14 |
Correct |
9 ms |
1628 KB |
Output is correct |
15 |
Correct |
9 ms |
1612 KB |
Output is correct |
16 |
Correct |
10 ms |
1612 KB |
Output is correct |
17 |
Correct |
9 ms |
1612 KB |
Output is correct |
18 |
Correct |
177 ms |
1220 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
88 ms |
1376 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
1612 KB |
Output is correct |
2 |
Correct |
10 ms |
1608 KB |
Output is correct |
3 |
Correct |
10 ms |
1572 KB |
Output is correct |
4 |
Correct |
8 ms |
1396 KB |
Output is correct |
5 |
Correct |
1 ms |
588 KB |
Output is correct |
6 |
Correct |
5 ms |
1056 KB |
Output is correct |
7 |
Correct |
6 ms |
1228 KB |
Output is correct |
8 |
Correct |
6 ms |
1228 KB |
Output is correct |
9 |
Correct |
6 ms |
1228 KB |
Output is correct |
10 |
Correct |
2 ms |
716 KB |
Output is correct |
11 |
Correct |
6 ms |
1184 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
47 ms |
1224 KB |
3rd lines differ - on the 42nd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |