#include "train.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v)
{
int n = a.size(), m = u.size();
vector<vector<int>> E(n), R(n);
for (int i = 0; i < m; i++)
E[u[i]].emplace_back(v[i]),
R[v[i]].emplace_back(u[i]);
vector<int> loop(n, 0);
for (int i = 0; i < n; i++)
{
vector<int> req(n, 0);
for (int j = 0; j < n; j++)
if (r[j])
req[j] = 1e9;
else if (a[j])
req[j] = E[j].size();
else
req[j] = 1;
queue<int> q;
q.push(i);
while (!q.empty())
{
int x = q.front();
q.pop();
for (auto y : R[x])
if (--req[y] == 0)
q.emplace(y);
}
loop[i] = req[i] <= 0;
}
vector<int> ans(n, 1);
vector<int> req(n, 0);
queue<int> q;
for (int j = 0; j < n; j++)
if (loop[j])
{
q.push(j);
req[j] = 0;
}
else if (a[j])
req[j] = E[j].size();
else
req[j] = 1;
while (!q.empty())
{
int x = q.front();
ans[x] = 0;
q.pop();
for (auto y : R[x])
if (--req[y] == 0)
q.emplace(y);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
49 ms |
1068 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
3rd lines differ - on the 4th token, expected: '0', found: '1' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
149 ms |
1424 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
1216 KB |
Output is correct |
2 |
Correct |
114 ms |
1468 KB |
Output is correct |
3 |
Correct |
156 ms |
1560 KB |
Output is correct |
4 |
Correct |
97 ms |
1560 KB |
Output is correct |
5 |
Correct |
254 ms |
1568 KB |
Output is correct |
6 |
Correct |
257 ms |
1612 KB |
Output is correct |
7 |
Correct |
226 ms |
1560 KB |
Output is correct |
8 |
Correct |
142 ms |
1508 KB |
Output is correct |
9 |
Correct |
37 ms |
1456 KB |
Output is correct |
10 |
Correct |
42 ms |
1492 KB |
Output is correct |
11 |
Correct |
30 ms |
1576 KB |
Output is correct |
12 |
Correct |
36 ms |
1580 KB |
Output is correct |
13 |
Correct |
373 ms |
1572 KB |
Output is correct |
14 |
Correct |
224 ms |
1464 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
412 ms |
1364 KB |
Output is correct |
2 |
Correct |
35 ms |
1368 KB |
Output is correct |
3 |
Correct |
174 ms |
1376 KB |
Output is correct |
4 |
Correct |
61 ms |
1296 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Incorrect |
45 ms |
996 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
49 ms |
1068 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |