Submission #52076

# Submission time Handle Problem Language Result Execution time Memory
52076 2018-06-23T16:50:17 Z aome Toy Train (IOI17_train) C++17
100 / 100
569 ms 10600 KB
#include "train.h"

#include <bits/stdc++.h>

using namespace std;

const int N = 5005;

int deg[N];
bool visit[N];
vector<int> G1[N], G2[N];

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
	int n = a.size(), m = u.size();
	for (int i = 0; i < m; ++i) {
		G1[u[i]].push_back(v[i]), G2[v[i]].push_back(u[i]);
	}
	vector<int> res(n, 0);
	while (1) {
		for (int i = 0; i < n; ++i) visit[i] = 0;
		queue<int> qu;
		for (int i = 0; i < n; ++i) {
			deg[i] = G1[i].size();
		}
		for (int i = 0; i < n; ++i) {
			if (r[i]) qu.push(i);
		}
		while (qu.size()) {
			int u = qu.front(); qu.pop();
			for (auto v : G2[u]) {
				if (a[v]) {
					if (!visit[v]) {
						visit[v] = 1;
						if (!r[v]) qu.push(v);
					}
				}
				else {
					deg[v]--;
					if (deg[v] == 0) {
						visit[v] = 1;
						if (!r[v]) qu.push(v);
					}
				}
			}
		}
		bool flag = 0;
		for (int i = 0; i < n; ++i) {
			if (r[i] && !visit[i]) { r[i] = 0, flag = 1; }
		}
		if (flag) continue;
		for (int i = 0; i < n; ++i) res[i] = visit[i];
		break;
	}
	return res;
}
# Verdict Execution time Memory Grader output
1 Correct 13 ms 1144 KB Output is correct
2 Correct 10 ms 1256 KB Output is correct
3 Correct 15 ms 1408 KB Output is correct
4 Correct 12 ms 1428 KB Output is correct
5 Correct 11 ms 1640 KB Output is correct
6 Correct 15 ms 1796 KB Output is correct
7 Correct 11 ms 1936 KB Output is correct
8 Correct 12 ms 1936 KB Output is correct
9 Correct 10 ms 2056 KB Output is correct
10 Correct 10 ms 2112 KB Output is correct
11 Correct 6 ms 2136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2136 KB Output is correct
2 Correct 2 ms 2136 KB Output is correct
3 Correct 2 ms 2136 KB Output is correct
4 Correct 3 ms 2136 KB Output is correct
5 Correct 3 ms 2136 KB Output is correct
6 Correct 3 ms 2136 KB Output is correct
7 Correct 3 ms 2136 KB Output is correct
8 Correct 2 ms 2136 KB Output is correct
9 Correct 2 ms 2136 KB Output is correct
10 Correct 3 ms 2136 KB Output is correct
11 Correct 3 ms 2136 KB Output is correct
12 Correct 3 ms 2136 KB Output is correct
13 Correct 3 ms 2136 KB Output is correct
14 Correct 4 ms 2136 KB Output is correct
15 Correct 2 ms 2136 KB Output is correct
16 Correct 4 ms 2136 KB Output is correct
17 Correct 2 ms 2136 KB Output is correct
18 Correct 2 ms 2136 KB Output is correct
19 Correct 3 ms 2136 KB Output is correct
20 Correct 3 ms 2136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 85 ms 2832 KB Output is correct
2 Correct 154 ms 2832 KB Output is correct
3 Correct 196 ms 2832 KB Output is correct
4 Correct 13 ms 2832 KB Output is correct
5 Correct 21 ms 2832 KB Output is correct
6 Correct 15 ms 2832 KB Output is correct
7 Correct 13 ms 2832 KB Output is correct
8 Correct 11 ms 2832 KB Output is correct
9 Correct 10 ms 2832 KB Output is correct
10 Correct 18 ms 2832 KB Output is correct
11 Correct 11 ms 2832 KB Output is correct
12 Correct 13 ms 2832 KB Output is correct
13 Correct 12 ms 2832 KB Output is correct
14 Correct 16 ms 2832 KB Output is correct
15 Correct 12 ms 2832 KB Output is correct
16 Correct 17 ms 2844 KB Output is correct
17 Correct 12 ms 2844 KB Output is correct
18 Correct 273 ms 2844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 2844 KB Output is correct
2 Correct 12 ms 2844 KB Output is correct
3 Correct 19 ms 3024 KB Output is correct
4 Correct 16 ms 3360 KB Output is correct
5 Correct 12 ms 3440 KB Output is correct
6 Correct 13 ms 3644 KB Output is correct
7 Correct 21 ms 3844 KB Output is correct
8 Correct 12 ms 4072 KB Output is correct
9 Correct 12 ms 4240 KB Output is correct
10 Correct 15 ms 4552 KB Output is correct
11 Correct 13 ms 4732 KB Output is correct
12 Correct 12 ms 5040 KB Output is correct
13 Correct 12 ms 5124 KB Output is correct
14 Correct 11 ms 5328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 5348 KB Output is correct
2 Correct 18 ms 5348 KB Output is correct
3 Correct 13 ms 5348 KB Output is correct
4 Correct 13 ms 5348 KB Output is correct
5 Correct 3 ms 5348 KB Output is correct
6 Correct 7 ms 5348 KB Output is correct
7 Correct 8 ms 5348 KB Output is correct
8 Correct 9 ms 5348 KB Output is correct
9 Correct 9 ms 5348 KB Output is correct
10 Correct 4 ms 5348 KB Output is correct
11 Correct 8 ms 5348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 1144 KB Output is correct
2 Correct 10 ms 1256 KB Output is correct
3 Correct 15 ms 1408 KB Output is correct
4 Correct 12 ms 1428 KB Output is correct
5 Correct 11 ms 1640 KB Output is correct
6 Correct 15 ms 1796 KB Output is correct
7 Correct 11 ms 1936 KB Output is correct
8 Correct 12 ms 1936 KB Output is correct
9 Correct 10 ms 2056 KB Output is correct
10 Correct 10 ms 2112 KB Output is correct
11 Correct 6 ms 2136 KB Output is correct
12 Correct 2 ms 2136 KB Output is correct
13 Correct 2 ms 2136 KB Output is correct
14 Correct 2 ms 2136 KB Output is correct
15 Correct 3 ms 2136 KB Output is correct
16 Correct 3 ms 2136 KB Output is correct
17 Correct 3 ms 2136 KB Output is correct
18 Correct 3 ms 2136 KB Output is correct
19 Correct 2 ms 2136 KB Output is correct
20 Correct 2 ms 2136 KB Output is correct
21 Correct 3 ms 2136 KB Output is correct
22 Correct 3 ms 2136 KB Output is correct
23 Correct 3 ms 2136 KB Output is correct
24 Correct 3 ms 2136 KB Output is correct
25 Correct 4 ms 2136 KB Output is correct
26 Correct 2 ms 2136 KB Output is correct
27 Correct 4 ms 2136 KB Output is correct
28 Correct 2 ms 2136 KB Output is correct
29 Correct 2 ms 2136 KB Output is correct
30 Correct 3 ms 2136 KB Output is correct
31 Correct 3 ms 2136 KB Output is correct
32 Correct 85 ms 2832 KB Output is correct
33 Correct 154 ms 2832 KB Output is correct
34 Correct 196 ms 2832 KB Output is correct
35 Correct 13 ms 2832 KB Output is correct
36 Correct 21 ms 2832 KB Output is correct
37 Correct 15 ms 2832 KB Output is correct
38 Correct 13 ms 2832 KB Output is correct
39 Correct 11 ms 2832 KB Output is correct
40 Correct 10 ms 2832 KB Output is correct
41 Correct 18 ms 2832 KB Output is correct
42 Correct 11 ms 2832 KB Output is correct
43 Correct 13 ms 2832 KB Output is correct
44 Correct 12 ms 2832 KB Output is correct
45 Correct 16 ms 2832 KB Output is correct
46 Correct 12 ms 2832 KB Output is correct
47 Correct 17 ms 2844 KB Output is correct
48 Correct 12 ms 2844 KB Output is correct
49 Correct 273 ms 2844 KB Output is correct
50 Correct 10 ms 2844 KB Output is correct
51 Correct 12 ms 2844 KB Output is correct
52 Correct 19 ms 3024 KB Output is correct
53 Correct 16 ms 3360 KB Output is correct
54 Correct 12 ms 3440 KB Output is correct
55 Correct 13 ms 3644 KB Output is correct
56 Correct 21 ms 3844 KB Output is correct
57 Correct 12 ms 4072 KB Output is correct
58 Correct 12 ms 4240 KB Output is correct
59 Correct 15 ms 4552 KB Output is correct
60 Correct 13 ms 4732 KB Output is correct
61 Correct 12 ms 5040 KB Output is correct
62 Correct 12 ms 5124 KB Output is correct
63 Correct 11 ms 5328 KB Output is correct
64 Correct 11 ms 5348 KB Output is correct
65 Correct 18 ms 5348 KB Output is correct
66 Correct 13 ms 5348 KB Output is correct
67 Correct 13 ms 5348 KB Output is correct
68 Correct 3 ms 5348 KB Output is correct
69 Correct 7 ms 5348 KB Output is correct
70 Correct 8 ms 5348 KB Output is correct
71 Correct 9 ms 5348 KB Output is correct
72 Correct 9 ms 5348 KB Output is correct
73 Correct 4 ms 5348 KB Output is correct
74 Correct 8 ms 5348 KB Output is correct
75 Correct 109 ms 5604 KB Output is correct
76 Correct 143 ms 5824 KB Output is correct
77 Correct 209 ms 6028 KB Output is correct
78 Correct 198 ms 6192 KB Output is correct
79 Correct 193 ms 6528 KB Output is correct
80 Correct 14 ms 6612 KB Output is correct
81 Correct 13 ms 6816 KB Output is correct
82 Correct 13 ms 7024 KB Output is correct
83 Correct 14 ms 7232 KB Output is correct
84 Correct 14 ms 7424 KB Output is correct
85 Correct 14 ms 7624 KB Output is correct
86 Correct 17 ms 7856 KB Output is correct
87 Correct 13 ms 7936 KB Output is correct
88 Correct 19 ms 8272 KB Output is correct
89 Correct 13 ms 8480 KB Output is correct
90 Correct 28 ms 8688 KB Output is correct
91 Correct 29 ms 8896 KB Output is correct
92 Correct 45 ms 9232 KB Output is correct
93 Correct 35 ms 9232 KB Output is correct
94 Correct 38 ms 9520 KB Output is correct
95 Correct 51 ms 9856 KB Output is correct
96 Correct 90 ms 9944 KB Output is correct
97 Correct 297 ms 10120 KB Output is correct
98 Correct 543 ms 10308 KB Output is correct
99 Correct 569 ms 10532 KB Output is correct
100 Correct 315 ms 10600 KB Output is correct