#include <bits/stdc++.h>
using namespace std;
const int MX = 5042;
int n;
int deg[MX];
int nxt[MX];
bool vis[MX];
bool vis2[MX];
bool isOk[MX];
bool isAlice[MX];
bool isCharge[MX];
vector<int> rgraph[MX];
bool BFS() {
int start = 0;
int end = 0;
for (int i = 0; i < n; i++)
deg[i] = 0;
for (int i = 0; i < n; i++) {
for (auto& x: rgraph[i])
deg[x]++;
if (isCharge[i] && isOk[i])
nxt[end++] = i;
vis[i] = vis2[i] = false;
}
//cout << layer << ' ' << (int)nxt.size() << '\n';
while (start < end) {
auto cur = nxt[start++];
//cout << "cur is " << cur << '\n';
if (vis[cur])
continue;
vis[cur] = true;
for (auto& x: rgraph[cur]) {
if (!vis2[x] && ((--deg[x] == 0) || isAlice[x])) {
vis2[x] = true;
nxt[end++] = x;
}
}
}
for (int i = 0; i < n; i++) {
if (isOk[i] && !vis2[i]) {
isOk[i] = false;
return true;
}
}
return false;
}
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
n = (int)a.size();
for (int i = 0; i < (int)u.size(); i++)
rgraph[v[i]].push_back(u[i]);
for (int i = 0; i < n; i++) {
isAlice[i] = a[i];
isCharge[i] = r[i];
isOk[i] = true;
}
while (BFS());
vector<int> ans (n);
for (int i = 0; i < n; i++)
ans[i] = isOk[i];
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
315 ms |
816 KB |
3rd lines differ - on the 26th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
428 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
428 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
424 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
424 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
25 ms |
1116 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
746 ms |
940 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
526 ms |
1056 KB |
Output is correct |
2 |
Correct |
6 ms |
1108 KB |
Output is correct |
3 |
Correct |
328 ms |
1064 KB |
Output is correct |
4 |
Correct |
6 ms |
984 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
248 ms |
724 KB |
Output is correct |
7 |
Correct |
24 ms |
852 KB |
Output is correct |
8 |
Correct |
44 ms |
920 KB |
Output is correct |
9 |
Correct |
32 ms |
852 KB |
Output is correct |
10 |
Correct |
3 ms |
596 KB |
Output is correct |
11 |
Correct |
13 ms |
852 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
315 ms |
816 KB |
3rd lines differ - on the 26th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |