#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1000000000000000000LL;
ll n, m, q, k, x, y, a, c;
vector<ll> G[5000];
vector<ll> Gr[5000];
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
n = a.size();
m = u.size();
vector<ll> cnt(n);
vector<int> ans(n);
for (int i = 0; i < n; i++) {
G[i].clear();
Gr[i].clear();
}
for (int i = 0; i < m; i++) {
cnt[u[i]]++;
G[v[i]].push_back(u[i]);
Gr[u[i]].push_back(v[i]);
}
auto cnt1 = cnt;
for (int i = 0; i < n; i++) {
if (ans[i]) {
continue;
}
if (r[i]) {
cnt = cnt1;
queue<ll> q;
vector<int> vis(n);
q.push(i);
while (!q.empty()) {
ll x = q.front();
q.pop();
if (vis[x]) {
continue;
}
vis[x] = 1;
for (auto j : G[x]) {
if (a[j] && !vis[j]) {
q.push(j);
}
if (!a[j]) {
cnt[j]--;
if (cnt[j] == 0 && !vis[j]) {
q.push(j);
}
}
}
}
bool fl = 0;
for (int j : Gr[i]) {
if (vis[j]) {
fl = 1;
break;
}
}
if (fl) {
for (int j = 0; j < n; j++) {
ans[j] |= vis[j];
}
}
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
1372 KB |
3rd lines differ - on the 42nd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
604 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
1884 KB |
Output is correct |
2 |
Correct |
52 ms |
1880 KB |
Output is correct |
3 |
Correct |
67 ms |
1976 KB |
Output is correct |
4 |
Correct |
7 ms |
1880 KB |
Output is correct |
5 |
Correct |
36 ms |
2068 KB |
Output is correct |
6 |
Correct |
13 ms |
1880 KB |
Output is correct |
7 |
Correct |
9 ms |
1884 KB |
Output is correct |
8 |
Correct |
5 ms |
1884 KB |
Output is correct |
9 |
Correct |
5 ms |
1892 KB |
Output is correct |
10 |
Correct |
6 ms |
1736 KB |
Output is correct |
11 |
Correct |
5 ms |
1888 KB |
Output is correct |
12 |
Correct |
5 ms |
1716 KB |
Output is correct |
13 |
Correct |
6 ms |
1892 KB |
Output is correct |
14 |
Correct |
9 ms |
1888 KB |
Output is correct |
15 |
Correct |
7 ms |
1884 KB |
Output is correct |
16 |
Correct |
5 ms |
1884 KB |
Output is correct |
17 |
Correct |
6 ms |
1896 KB |
Output is correct |
18 |
Correct |
110 ms |
1424 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
1752 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
1888 KB |
Output is correct |
2 |
Correct |
6 ms |
1892 KB |
Output is correct |
3 |
Correct |
6 ms |
2020 KB |
Output is correct |
4 |
Correct |
6 ms |
2140 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
3 ms |
1116 KB |
Output is correct |
7 |
Correct |
3 ms |
1628 KB |
Output is correct |
8 |
Correct |
4 ms |
1628 KB |
Output is correct |
9 |
Correct |
4 ms |
1628 KB |
Output is correct |
10 |
Correct |
1 ms |
860 KB |
Output is correct |
11 |
Correct |
3 ms |
1376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
1372 KB |
3rd lines differ - on the 42nd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |