#include <bits/stdc++.h>
using namespace std;
const int N = 5000;
vector<int> to[N], from[N], r;
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 (r[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(), ::r = r;
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);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
46 ms |
1220 KB |
3rd lines differ - on the 27th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
536 KB |
3rd lines differ - on the 9th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
1576 KB |
Output is correct |
2 |
Correct |
25 ms |
1636 KB |
Output is correct |
3 |
Correct |
33 ms |
1600 KB |
Output is correct |
4 |
Incorrect |
31 ms |
1584 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
933 ms |
1404 KB |
3rd lines differ - on the 696th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
1612 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
46 ms |
1220 KB |
3rd lines differ - on the 27th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |