#include "train.h"
#include<cstdio>
#include<algorithm>
using namespace std;
int n, m, D[5010], TD[5010], U[5010];
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
n = a.size();
m = u.size();
int i, j, k;
for (i = 0; i < n; i++) {
if (r[i] == 1)D[i] = 1;
else D[i] = 0;
}
for (i = 0; i < 15000; i++) {
for (k = 0; k < n; k++) {
if (a[k] == 1)TD[k] = 0;
else TD[k] = 1e9;
}
for (j = 0; j < m; j++) {
if (a[u[j]] == 1) {
TD[u[j]] = max(TD[u[j]], r[u[j]] + D[v[j]]);
}
else {
TD[u[j]] = min(TD[u[j]], r[u[j]] + D[v[j]]);
}
}
for (j = 0; j < n; j++) {
if (i == 9999)U[j] = TD[j];
D[j] = TD[j];
}
}
vector<int>res(n);
for (j = 0; j < n; j++) {
if (D[j] != U[j])res[j] = 1;
else res[j] = 0;
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1039 ms |
632 KB |
Output is correct |
2 |
Correct |
1081 ms |
836 KB |
Output is correct |
3 |
Correct |
1004 ms |
900 KB |
Output is correct |
4 |
Correct |
970 ms |
960 KB |
Output is correct |
5 |
Correct |
991 ms |
960 KB |
Output is correct |
6 |
Correct |
976 ms |
960 KB |
Output is correct |
7 |
Correct |
447 ms |
960 KB |
Output is correct |
8 |
Correct |
444 ms |
960 KB |
Output is correct |
9 |
Correct |
1134 ms |
960 KB |
Output is correct |
10 |
Correct |
908 ms |
972 KB |
Output is correct |
11 |
Correct |
789 ms |
972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
972 KB |
Output is correct |
2 |
Correct |
3 ms |
972 KB |
Output is correct |
3 |
Correct |
4 ms |
972 KB |
Output is correct |
4 |
Correct |
5 ms |
972 KB |
Output is correct |
5 |
Correct |
3 ms |
972 KB |
Output is correct |
6 |
Correct |
4 ms |
972 KB |
Output is correct |
7 |
Correct |
3 ms |
972 KB |
Output is correct |
8 |
Correct |
4 ms |
972 KB |
Output is correct |
9 |
Correct |
5 ms |
972 KB |
Output is correct |
10 |
Correct |
4 ms |
972 KB |
Output is correct |
11 |
Correct |
6 ms |
972 KB |
Output is correct |
12 |
Correct |
5 ms |
972 KB |
Output is correct |
13 |
Correct |
4 ms |
972 KB |
Output is correct |
14 |
Correct |
5 ms |
972 KB |
Output is correct |
15 |
Correct |
4 ms |
972 KB |
Output is correct |
16 |
Correct |
3 ms |
972 KB |
Output is correct |
17 |
Correct |
3 ms |
972 KB |
Output is correct |
18 |
Correct |
3 ms |
972 KB |
Output is correct |
19 |
Correct |
3 ms |
972 KB |
Output is correct |
20 |
Correct |
3 ms |
972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
792 ms |
1212 KB |
Output is correct |
2 |
Correct |
829 ms |
1452 KB |
Output is correct |
3 |
Correct |
788 ms |
1452 KB |
Output is correct |
4 |
Correct |
1045 ms |
1452 KB |
Output is correct |
5 |
Correct |
1110 ms |
1452 KB |
Output is correct |
6 |
Correct |
1171 ms |
1452 KB |
Output is correct |
7 |
Correct |
1101 ms |
1452 KB |
Output is correct |
8 |
Correct |
1085 ms |
1452 KB |
Output is correct |
9 |
Correct |
909 ms |
1452 KB |
Output is correct |
10 |
Correct |
1020 ms |
1452 KB |
Output is correct |
11 |
Correct |
1047 ms |
1452 KB |
Output is correct |
12 |
Correct |
1101 ms |
1452 KB |
Output is correct |
13 |
Correct |
1186 ms |
1452 KB |
Output is correct |
14 |
Correct |
1121 ms |
1452 KB |
Output is correct |
15 |
Correct |
1098 ms |
1452 KB |
Output is correct |
16 |
Correct |
1126 ms |
1452 KB |
Output is correct |
17 |
Correct |
1178 ms |
1452 KB |
Output is correct |
18 |
Correct |
632 ms |
1452 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
989 ms |
1452 KB |
Output is correct |
2 |
Correct |
985 ms |
1452 KB |
Output is correct |
3 |
Correct |
1153 ms |
1452 KB |
Output is correct |
4 |
Correct |
1165 ms |
1452 KB |
Output is correct |
5 |
Correct |
1180 ms |
1452 KB |
Output is correct |
6 |
Correct |
1070 ms |
1452 KB |
Output is correct |
7 |
Correct |
1090 ms |
1452 KB |
Output is correct |
8 |
Correct |
1029 ms |
1452 KB |
Output is correct |
9 |
Correct |
1029 ms |
1452 KB |
Output is correct |
10 |
Correct |
1298 ms |
1452 KB |
Output is correct |
11 |
Correct |
1110 ms |
1464 KB |
Output is correct |
12 |
Correct |
1117 ms |
1464 KB |
Output is correct |
13 |
Correct |
1165 ms |
1464 KB |
Output is correct |
14 |
Correct |
990 ms |
1464 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1713 ms |
1464 KB |
Output is correct |
2 |
Correct |
1571 ms |
1464 KB |
Output is correct |
3 |
Execution timed out |
2061 ms |
1464 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1039 ms |
632 KB |
Output is correct |
2 |
Correct |
1081 ms |
836 KB |
Output is correct |
3 |
Correct |
1004 ms |
900 KB |
Output is correct |
4 |
Correct |
970 ms |
960 KB |
Output is correct |
5 |
Correct |
991 ms |
960 KB |
Output is correct |
6 |
Correct |
976 ms |
960 KB |
Output is correct |
7 |
Correct |
447 ms |
960 KB |
Output is correct |
8 |
Correct |
444 ms |
960 KB |
Output is correct |
9 |
Correct |
1134 ms |
960 KB |
Output is correct |
10 |
Correct |
908 ms |
972 KB |
Output is correct |
11 |
Correct |
789 ms |
972 KB |
Output is correct |
12 |
Correct |
4 ms |
972 KB |
Output is correct |
13 |
Correct |
3 ms |
972 KB |
Output is correct |
14 |
Correct |
4 ms |
972 KB |
Output is correct |
15 |
Correct |
5 ms |
972 KB |
Output is correct |
16 |
Correct |
3 ms |
972 KB |
Output is correct |
17 |
Correct |
4 ms |
972 KB |
Output is correct |
18 |
Correct |
3 ms |
972 KB |
Output is correct |
19 |
Correct |
4 ms |
972 KB |
Output is correct |
20 |
Correct |
5 ms |
972 KB |
Output is correct |
21 |
Correct |
4 ms |
972 KB |
Output is correct |
22 |
Correct |
6 ms |
972 KB |
Output is correct |
23 |
Correct |
5 ms |
972 KB |
Output is correct |
24 |
Correct |
4 ms |
972 KB |
Output is correct |
25 |
Correct |
5 ms |
972 KB |
Output is correct |
26 |
Correct |
4 ms |
972 KB |
Output is correct |
27 |
Correct |
3 ms |
972 KB |
Output is correct |
28 |
Correct |
3 ms |
972 KB |
Output is correct |
29 |
Correct |
3 ms |
972 KB |
Output is correct |
30 |
Correct |
3 ms |
972 KB |
Output is correct |
31 |
Correct |
3 ms |
972 KB |
Output is correct |
32 |
Correct |
792 ms |
1212 KB |
Output is correct |
33 |
Correct |
829 ms |
1452 KB |
Output is correct |
34 |
Correct |
788 ms |
1452 KB |
Output is correct |
35 |
Correct |
1045 ms |
1452 KB |
Output is correct |
36 |
Correct |
1110 ms |
1452 KB |
Output is correct |
37 |
Correct |
1171 ms |
1452 KB |
Output is correct |
38 |
Correct |
1101 ms |
1452 KB |
Output is correct |
39 |
Correct |
1085 ms |
1452 KB |
Output is correct |
40 |
Correct |
909 ms |
1452 KB |
Output is correct |
41 |
Correct |
1020 ms |
1452 KB |
Output is correct |
42 |
Correct |
1047 ms |
1452 KB |
Output is correct |
43 |
Correct |
1101 ms |
1452 KB |
Output is correct |
44 |
Correct |
1186 ms |
1452 KB |
Output is correct |
45 |
Correct |
1121 ms |
1452 KB |
Output is correct |
46 |
Correct |
1098 ms |
1452 KB |
Output is correct |
47 |
Correct |
1126 ms |
1452 KB |
Output is correct |
48 |
Correct |
1178 ms |
1452 KB |
Output is correct |
49 |
Correct |
632 ms |
1452 KB |
Output is correct |
50 |
Correct |
989 ms |
1452 KB |
Output is correct |
51 |
Correct |
985 ms |
1452 KB |
Output is correct |
52 |
Correct |
1153 ms |
1452 KB |
Output is correct |
53 |
Correct |
1165 ms |
1452 KB |
Output is correct |
54 |
Correct |
1180 ms |
1452 KB |
Output is correct |
55 |
Correct |
1070 ms |
1452 KB |
Output is correct |
56 |
Correct |
1090 ms |
1452 KB |
Output is correct |
57 |
Correct |
1029 ms |
1452 KB |
Output is correct |
58 |
Correct |
1029 ms |
1452 KB |
Output is correct |
59 |
Correct |
1298 ms |
1452 KB |
Output is correct |
60 |
Correct |
1110 ms |
1464 KB |
Output is correct |
61 |
Correct |
1117 ms |
1464 KB |
Output is correct |
62 |
Correct |
1165 ms |
1464 KB |
Output is correct |
63 |
Correct |
990 ms |
1464 KB |
Output is correct |
64 |
Correct |
1713 ms |
1464 KB |
Output is correct |
65 |
Correct |
1571 ms |
1464 KB |
Output is correct |
66 |
Execution timed out |
2061 ms |
1464 KB |
Time limit exceeded |
67 |
Halted |
0 ms |
0 KB |
- |