답안 #430568

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
430568 2021-06-16T16:05:35 Z rainboy 장난감 기차 (IOI17_train) C++
100 / 100
1982 ms 117996 KB
#include "train.h"
#include <stdlib.h>

using namespace std;

const int N = 5000;

typedef vector<int> vi;

int *ej[N], eo[N], dd[N][N + 1], out[N], qu[N * (N + 1)], n; char rr[N];

vi who_wins(vi aa, vi rr_, vi uu, vi vv) {
	int m = uu.size(), h, i, j, t, t_, cnt;
	vi ans(n = aa.size());

	for (i = 0; i < n; i++)
		rr[i] = rr_[i];
	for (h = 0; h < m; h++)
		out[uu[h]]++, eo[vv[h]]++;
	for (i = 0; i < n; i++)
		ej[i] = (int *) malloc(eo[i] * sizeof *ej[i]), eo[i] = 0;
	for (h = 0; h < m; h++)
		ej[vv[h]][eo[vv[h]]++] = uu[h];
	for (i = 0; i < n; i++) {
		dd[i][0] = !rr[i] ? 1 : 0;
		for (t = 1; t <= n; t++)
			dd[i][t] = t == n || !rr[i] ? (aa[i] ? out[i] : 1) : 0;
	}
	cnt = 0;
	for (i = 0; i < n; i++)
		if (--dd[i][0] == 0)
			qu[cnt++] = i * (n + 1) + 0;
	while (cnt) {
		int it = qu[--cnt], o;

		i = it / (n + 1), t = it % (n + 1);
		dd[i][t] = -1;
		for (o = eo[i]; o--; ) {
			j = ej[i][o];
			if (t != n) {
				if (--dd[j][t + 1] == 0)
					qu[cnt++] = j * (n + 1) + t + 1;
			} else if (rr[i])
				for (t_ = 1; t_ <= n; t_++)
					if (--dd[j][t_] == 0)
						qu[cnt++] = j * (n + 1) + t_;
		}
	}
	for (i = 0; i < n; i++)
		ans[i] = dd[i][n] >= 0;
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 265 ms 98884 KB Output is correct
2 Correct 266 ms 98800 KB Output is correct
3 Correct 256 ms 98884 KB Output is correct
4 Correct 269 ms 98884 KB Output is correct
5 Correct 282 ms 98912 KB Output is correct
6 Correct 269 ms 98828 KB Output is correct
7 Correct 404 ms 99096 KB Output is correct
8 Correct 134 ms 98636 KB Output is correct
9 Correct 275 ms 98860 KB Output is correct
10 Correct 308 ms 98688 KB Output is correct
11 Correct 341 ms 98628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1484 ms 99056 KB Output is correct
2 Correct 1185 ms 99048 KB Output is correct
3 Correct 882 ms 99044 KB Output is correct
4 Correct 271 ms 98984 KB Output is correct
5 Correct 731 ms 99112 KB Output is correct
6 Correct 1982 ms 99180 KB Output is correct
7 Correct 95 ms 99008 KB Output is correct
8 Correct 1282 ms 99036 KB Output is correct
9 Correct 1408 ms 98988 KB Output is correct
10 Correct 565 ms 99008 KB Output is correct
11 Correct 715 ms 98992 KB Output is correct
12 Correct 1338 ms 98952 KB Output is correct
13 Correct 111 ms 99012 KB Output is correct
14 Correct 116 ms 99016 KB Output is correct
15 Correct 113 ms 98972 KB Output is correct
16 Correct 108 ms 98916 KB Output is correct
17 Correct 116 ms 99008 KB Output is correct
18 Correct 434 ms 98744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 71 ms 98884 KB Output is correct
2 Correct 400 ms 103044 KB Output is correct
3 Correct 1101 ms 114612 KB Output is correct
4 Correct 585 ms 99972 KB Output is correct
5 Correct 831 ms 99144 KB Output is correct
6 Correct 548 ms 99156 KB Output is correct
7 Correct 535 ms 99160 KB Output is correct
8 Correct 1020 ms 99308 KB Output is correct
9 Correct 143 ms 99012 KB Output is correct
10 Correct 80 ms 98912 KB Output is correct
11 Correct 75 ms 98944 KB Output is correct
12 Correct 78 ms 99012 KB Output is correct
13 Correct 1225 ms 99072 KB Output is correct
14 Correct 638 ms 99012 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1306 ms 99048 KB Output is correct
2 Correct 115 ms 98708 KB Output is correct
3 Correct 600 ms 98992 KB Output is correct
4 Correct 109 ms 98756 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1393 ms 98600 KB Output is correct
7 Correct 23 ms 3660 KB Output is correct
8 Correct 65 ms 3740 KB Output is correct
9 Correct 32 ms 3716 KB Output is correct
10 Correct 3 ms 716 KB Output is correct
11 Correct 24 ms 6092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 265 ms 98884 KB Output is correct
2 Correct 266 ms 98800 KB Output is correct
3 Correct 256 ms 98884 KB Output is correct
4 Correct 269 ms 98884 KB Output is correct
5 Correct 282 ms 98912 KB Output is correct
6 Correct 269 ms 98828 KB Output is correct
7 Correct 404 ms 99096 KB Output is correct
8 Correct 134 ms 98636 KB Output is correct
9 Correct 275 ms 98860 KB Output is correct
10 Correct 308 ms 98688 KB Output is correct
11 Correct 341 ms 98628 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 0 ms 332 KB Output is correct
25 Correct 0 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1484 ms 99056 KB Output is correct
33 Correct 1185 ms 99048 KB Output is correct
34 Correct 882 ms 99044 KB Output is correct
35 Correct 271 ms 98984 KB Output is correct
36 Correct 731 ms 99112 KB Output is correct
37 Correct 1982 ms 99180 KB Output is correct
38 Correct 95 ms 99008 KB Output is correct
39 Correct 1282 ms 99036 KB Output is correct
40 Correct 1408 ms 98988 KB Output is correct
41 Correct 565 ms 99008 KB Output is correct
42 Correct 715 ms 98992 KB Output is correct
43 Correct 1338 ms 98952 KB Output is correct
44 Correct 111 ms 99012 KB Output is correct
45 Correct 116 ms 99016 KB Output is correct
46 Correct 113 ms 98972 KB Output is correct
47 Correct 108 ms 98916 KB Output is correct
48 Correct 116 ms 99008 KB Output is correct
49 Correct 434 ms 98744 KB Output is correct
50 Correct 71 ms 98884 KB Output is correct
51 Correct 400 ms 103044 KB Output is correct
52 Correct 1101 ms 114612 KB Output is correct
53 Correct 585 ms 99972 KB Output is correct
54 Correct 831 ms 99144 KB Output is correct
55 Correct 548 ms 99156 KB Output is correct
56 Correct 535 ms 99160 KB Output is correct
57 Correct 1020 ms 99308 KB Output is correct
58 Correct 143 ms 99012 KB Output is correct
59 Correct 80 ms 98912 KB Output is correct
60 Correct 75 ms 98944 KB Output is correct
61 Correct 78 ms 99012 KB Output is correct
62 Correct 1225 ms 99072 KB Output is correct
63 Correct 638 ms 99012 KB Output is correct
64 Correct 1306 ms 99048 KB Output is correct
65 Correct 115 ms 98708 KB Output is correct
66 Correct 600 ms 98992 KB Output is correct
67 Correct 109 ms 98756 KB Output is correct
68 Correct 1 ms 460 KB Output is correct
69 Correct 1393 ms 98600 KB Output is correct
70 Correct 23 ms 3660 KB Output is correct
71 Correct 65 ms 3740 KB Output is correct
72 Correct 32 ms 3716 KB Output is correct
73 Correct 3 ms 716 KB Output is correct
74 Correct 24 ms 6092 KB Output is correct
75 Correct 986 ms 99020 KB Output is correct
76 Correct 1148 ms 99104 KB Output is correct
77 Correct 840 ms 99012 KB Output is correct
78 Correct 840 ms 99092 KB Output is correct
79 Correct 862 ms 99096 KB Output is correct
80 Correct 217 ms 99016 KB Output is correct
81 Correct 1890 ms 99404 KB Output is correct
82 Correct 801 ms 107468 KB Output is correct
83 Correct 678 ms 99420 KB Output is correct
84 Correct 1050 ms 100560 KB Output is correct
85 Correct 1026 ms 117996 KB Output is correct
86 Correct 1177 ms 99544 KB Output is correct
87 Correct 1660 ms 113288 KB Output is correct
88 Correct 1073 ms 100396 KB Output is correct
89 Correct 942 ms 101008 KB Output is correct
90 Correct 1190 ms 102312 KB Output is correct
91 Correct 1160 ms 99228 KB Output is correct
92 Correct 830 ms 99316 KB Output is correct
93 Correct 767 ms 102596 KB Output is correct
94 Correct 930 ms 99768 KB Output is correct
95 Correct 742 ms 99520 KB Output is correct
96 Correct 299 ms 99432 KB Output is correct
97 Correct 701 ms 99212 KB Output is correct
98 Correct 560 ms 99148 KB Output is correct
99 Correct 575 ms 99008 KB Output is correct
100 Correct 440 ms 98756 KB Output is correct