Submission #393369

# Submission time Handle Problem Language Result Execution time Memory
393369 2021-04-23T10:07:12 Z huukhang Traffic (IOI10_traffic) C++11
100 / 100
1651 ms 158936 KB
#include "traffic.h"
#include <bits/stdc++.h>

using namespace std;
const int MX = 1e6;
const int INF = 2e9 + 1;

int fans = 0;

vector<int> g[MX], nodes(MX), people(MX), children(MX);

void dfs (int v, int parent) {

	for (auto x: g[v]) {
		if (x == parent) continue;
		dfs(x, v);
		children[v] += children[x];
		people[v] = max(people[v], children[x]);
	}

	people[v] = max(people[v], fans - children[v] - nodes[v]);

	children[v] += nodes[v];
}

int LocateCentre (int n, int p[], int d[], int s[]) {
	for (int i = 0; i < n; i++) {
		fans += p[i];
		nodes[i] = p[i];
	}

	for (int i = 0; i < n - 1; i++) {
		g[s[i]].push_back(d[i]);
		g[d[i]].push_back(s[i]);
	}

	dfs(0, -1);

	int sol = INF, res = -1;

	for (int i = 0; i < n; i++) {
		if (people[i] < sol) {
			res = i;
			sol = people[i];
		}
	}

	return res;
}
# Verdict Execution time Memory Grader output
1 Correct 22 ms 35500 KB Output is correct
2 Correct 21 ms 35564 KB Output is correct
3 Correct 21 ms 35504 KB Output is correct
4 Correct 21 ms 35472 KB Output is correct
5 Correct 21 ms 35532 KB Output is correct
6 Correct 21 ms 35508 KB Output is correct
7 Correct 25 ms 35536 KB Output is correct
8 Correct 22 ms 35552 KB Output is correct
9 Correct 22 ms 35532 KB Output is correct
10 Correct 22 ms 35520 KB Output is correct
11 Correct 21 ms 35500 KB Output is correct
12 Correct 21 ms 35532 KB Output is correct
13 Correct 21 ms 35480 KB Output is correct
14 Correct 21 ms 35524 KB Output is correct
15 Correct 21 ms 35532 KB Output is correct
16 Correct 23 ms 35532 KB Output is correct
17 Correct 21 ms 35532 KB Output is correct
18 Correct 24 ms 35532 KB Output is correct
19 Correct 24 ms 35588 KB Output is correct
20 Correct 24 ms 35532 KB Output is correct
21 Correct 23 ms 35472 KB Output is correct
22 Correct 21 ms 35532 KB Output is correct
23 Correct 21 ms 35444 KB Output is correct
24 Correct 22 ms 35532 KB Output is correct
25 Correct 24 ms 35548 KB Output is correct
26 Correct 21 ms 35488 KB Output is correct
27 Correct 23 ms 35552 KB Output is correct
28 Correct 25 ms 35496 KB Output is correct
29 Correct 25 ms 35456 KB Output is correct
30 Correct 24 ms 35552 KB Output is correct
31 Correct 22 ms 35500 KB Output is correct
32 Correct 21 ms 35548 KB Output is correct
33 Correct 21 ms 35552 KB Output is correct
34 Correct 21 ms 35532 KB Output is correct
35 Correct 21 ms 35532 KB Output is correct
36 Correct 22 ms 35556 KB Output is correct
37 Correct 22 ms 35636 KB Output is correct
38 Correct 23 ms 35556 KB Output is correct
39 Correct 22 ms 35536 KB Output is correct
40 Correct 22 ms 35660 KB Output is correct
41 Correct 21 ms 35556 KB Output is correct
42 Correct 22 ms 35660 KB Output is correct
43 Correct 23 ms 35476 KB Output is correct
44 Correct 22 ms 35504 KB Output is correct
45 Correct 21 ms 35544 KB Output is correct
46 Correct 21 ms 35532 KB Output is correct
47 Correct 21 ms 35532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 35500 KB Output is correct
2 Correct 21 ms 35564 KB Output is correct
3 Correct 21 ms 35504 KB Output is correct
4 Correct 21 ms 35472 KB Output is correct
5 Correct 21 ms 35532 KB Output is correct
6 Correct 21 ms 35508 KB Output is correct
7 Correct 25 ms 35536 KB Output is correct
8 Correct 22 ms 35552 KB Output is correct
9 Correct 22 ms 35532 KB Output is correct
10 Correct 22 ms 35520 KB Output is correct
11 Correct 21 ms 35500 KB Output is correct
12 Correct 21 ms 35532 KB Output is correct
13 Correct 21 ms 35480 KB Output is correct
14 Correct 21 ms 35524 KB Output is correct
15 Correct 21 ms 35532 KB Output is correct
16 Correct 23 ms 35532 KB Output is correct
17 Correct 21 ms 35532 KB Output is correct
18 Correct 24 ms 35532 KB Output is correct
19 Correct 24 ms 35588 KB Output is correct
20 Correct 24 ms 35532 KB Output is correct
21 Correct 23 ms 35472 KB Output is correct
22 Correct 21 ms 35532 KB Output is correct
23 Correct 21 ms 35444 KB Output is correct
24 Correct 22 ms 35532 KB Output is correct
25 Correct 24 ms 35548 KB Output is correct
26 Correct 21 ms 35488 KB Output is correct
27 Correct 23 ms 35552 KB Output is correct
28 Correct 25 ms 35496 KB Output is correct
29 Correct 25 ms 35456 KB Output is correct
30 Correct 24 ms 35552 KB Output is correct
31 Correct 22 ms 35500 KB Output is correct
32 Correct 21 ms 35548 KB Output is correct
33 Correct 21 ms 35552 KB Output is correct
34 Correct 21 ms 35532 KB Output is correct
35 Correct 21 ms 35532 KB Output is correct
36 Correct 22 ms 35556 KB Output is correct
37 Correct 22 ms 35636 KB Output is correct
38 Correct 23 ms 35556 KB Output is correct
39 Correct 22 ms 35536 KB Output is correct
40 Correct 22 ms 35660 KB Output is correct
41 Correct 21 ms 35556 KB Output is correct
42 Correct 22 ms 35660 KB Output is correct
43 Correct 23 ms 35476 KB Output is correct
44 Correct 22 ms 35504 KB Output is correct
45 Correct 21 ms 35544 KB Output is correct
46 Correct 21 ms 35532 KB Output is correct
47 Correct 21 ms 35532 KB Output is correct
48 Correct 23 ms 35540 KB Output is correct
49 Correct 22 ms 35544 KB Output is correct
50 Correct 23 ms 35448 KB Output is correct
51 Correct 21 ms 35520 KB Output is correct
52 Correct 25 ms 35548 KB Output is correct
53 Correct 21 ms 35532 KB Output is correct
54 Correct 21 ms 35544 KB Output is correct
55 Correct 21 ms 35540 KB Output is correct
56 Correct 21 ms 35536 KB Output is correct
57 Correct 21 ms 35536 KB Output is correct
58 Correct 21 ms 35540 KB Output is correct
59 Correct 21 ms 35508 KB Output is correct
60 Correct 22 ms 35432 KB Output is correct
61 Correct 22 ms 35564 KB Output is correct
62 Correct 22 ms 35480 KB Output is correct
63 Correct 21 ms 35452 KB Output is correct
64 Correct 24 ms 35532 KB Output is correct
65 Correct 20 ms 35532 KB Output is correct
66 Correct 21 ms 35532 KB Output is correct
67 Correct 22 ms 35564 KB Output is correct
68 Correct 43 ms 41588 KB Output is correct
69 Correct 66 ms 47680 KB Output is correct
70 Correct 24 ms 35500 KB Output is correct
71 Correct 91 ms 53952 KB Output is correct
72 Correct 122 ms 60136 KB Output is correct
73 Correct 135 ms 66300 KB Output is correct
74 Correct 163 ms 72476 KB Output is correct
75 Correct 209 ms 78660 KB Output is correct
76 Correct 205 ms 84960 KB Output is correct
77 Correct 260 ms 91092 KB Output is correct
78 Correct 256 ms 97316 KB Output is correct
79 Correct 289 ms 103492 KB Output is correct
80 Correct 313 ms 109616 KB Output is correct
81 Correct 22 ms 35508 KB Output is correct
82 Correct 323 ms 115876 KB Output is correct
83 Correct 358 ms 121948 KB Output is correct
84 Correct 374 ms 128204 KB Output is correct
85 Correct 414 ms 134324 KB Output is correct
86 Correct 437 ms 140472 KB Output is correct
87 Correct 486 ms 146752 KB Output is correct
88 Correct 723 ms 152900 KB Output is correct
89 Correct 869 ms 158936 KB Output is correct
90 Correct 21 ms 35532 KB Output is correct
91 Correct 22 ms 35496 KB Output is correct
92 Correct 21 ms 35500 KB Output is correct
93 Correct 21 ms 35536 KB Output is correct
94 Correct 23 ms 35532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 35500 KB Output is correct
2 Correct 21 ms 35564 KB Output is correct
3 Correct 21 ms 35504 KB Output is correct
4 Correct 21 ms 35472 KB Output is correct
5 Correct 21 ms 35532 KB Output is correct
6 Correct 21 ms 35508 KB Output is correct
7 Correct 25 ms 35536 KB Output is correct
8 Correct 22 ms 35552 KB Output is correct
9 Correct 22 ms 35532 KB Output is correct
10 Correct 22 ms 35520 KB Output is correct
11 Correct 21 ms 35500 KB Output is correct
12 Correct 21 ms 35532 KB Output is correct
13 Correct 21 ms 35480 KB Output is correct
14 Correct 21 ms 35524 KB Output is correct
15 Correct 21 ms 35532 KB Output is correct
16 Correct 23 ms 35532 KB Output is correct
17 Correct 21 ms 35532 KB Output is correct
18 Correct 24 ms 35532 KB Output is correct
19 Correct 24 ms 35588 KB Output is correct
20 Correct 24 ms 35532 KB Output is correct
21 Correct 23 ms 35472 KB Output is correct
22 Correct 21 ms 35532 KB Output is correct
23 Correct 21 ms 35444 KB Output is correct
24 Correct 22 ms 35532 KB Output is correct
25 Correct 24 ms 35548 KB Output is correct
26 Correct 21 ms 35488 KB Output is correct
27 Correct 23 ms 35552 KB Output is correct
28 Correct 25 ms 35496 KB Output is correct
29 Correct 25 ms 35456 KB Output is correct
30 Correct 24 ms 35552 KB Output is correct
31 Correct 22 ms 35500 KB Output is correct
32 Correct 21 ms 35548 KB Output is correct
33 Correct 21 ms 35552 KB Output is correct
34 Correct 21 ms 35532 KB Output is correct
35 Correct 21 ms 35532 KB Output is correct
36 Correct 22 ms 35556 KB Output is correct
37 Correct 22 ms 35636 KB Output is correct
38 Correct 23 ms 35556 KB Output is correct
39 Correct 22 ms 35536 KB Output is correct
40 Correct 22 ms 35660 KB Output is correct
41 Correct 21 ms 35556 KB Output is correct
42 Correct 22 ms 35660 KB Output is correct
43 Correct 23 ms 35476 KB Output is correct
44 Correct 22 ms 35504 KB Output is correct
45 Correct 21 ms 35544 KB Output is correct
46 Correct 21 ms 35532 KB Output is correct
47 Correct 21 ms 35532 KB Output is correct
48 Correct 21 ms 35548 KB Output is correct
49 Correct 21 ms 35532 KB Output is correct
50 Correct 20 ms 35532 KB Output is correct
51 Correct 22 ms 35532 KB Output is correct
52 Correct 21 ms 35532 KB Output is correct
53 Correct 22 ms 35532 KB Output is correct
54 Correct 22 ms 35532 KB Output is correct
55 Correct 21 ms 35532 KB Output is correct
56 Correct 22 ms 35492 KB Output is correct
57 Correct 21 ms 35532 KB Output is correct
58 Correct 22 ms 35536 KB Output is correct
59 Correct 21 ms 35520 KB Output is correct
60 Correct 21 ms 35532 KB Output is correct
61 Correct 21 ms 35532 KB Output is correct
62 Correct 21 ms 35532 KB Output is correct
63 Correct 21 ms 35512 KB Output is correct
64 Correct 21 ms 35484 KB Output is correct
65 Correct 22 ms 35436 KB Output is correct
66 Correct 22 ms 35544 KB Output is correct
67 Correct 22 ms 35488 KB Output is correct
68 Correct 22 ms 35532 KB Output is correct
69 Correct 24 ms 35516 KB Output is correct
70 Correct 21 ms 35540 KB Output is correct
71 Correct 21 ms 35440 KB Output is correct
72 Correct 22 ms 35532 KB Output is correct
73 Correct 23 ms 35560 KB Output is correct
74 Correct 22 ms 35460 KB Output is correct
75 Correct 21 ms 35532 KB Output is correct
76 Correct 21 ms 35484 KB Output is correct
77 Correct 21 ms 35468 KB Output is correct
78 Correct 21 ms 35552 KB Output is correct
79 Correct 22 ms 35544 KB Output is correct
80 Correct 21 ms 35544 KB Output is correct
81 Correct 22 ms 35532 KB Output is correct
82 Correct 21 ms 35532 KB Output is correct
83 Correct 22 ms 35504 KB Output is correct
84 Correct 21 ms 35556 KB Output is correct
85 Correct 23 ms 35532 KB Output is correct
86 Correct 22 ms 35536 KB Output is correct
87 Correct 22 ms 35532 KB Output is correct
88 Correct 22 ms 35524 KB Output is correct
89 Correct 22 ms 35556 KB Output is correct
90 Correct 21 ms 35652 KB Output is correct
91 Correct 22 ms 35532 KB Output is correct
92 Correct 21 ms 35456 KB Output is correct
93 Correct 22 ms 35516 KB Output is correct
94 Correct 21 ms 35532 KB Output is correct
95 Correct 21 ms 35668 KB Output is correct
96 Correct 21 ms 35472 KB Output is correct
97 Correct 21 ms 35512 KB Output is correct
98 Correct 21 ms 35532 KB Output is correct
99 Correct 21 ms 35536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 35500 KB Output is correct
2 Correct 21 ms 35564 KB Output is correct
3 Correct 21 ms 35504 KB Output is correct
4 Correct 21 ms 35472 KB Output is correct
5 Correct 21 ms 35532 KB Output is correct
6 Correct 21 ms 35508 KB Output is correct
7 Correct 25 ms 35536 KB Output is correct
8 Correct 22 ms 35552 KB Output is correct
9 Correct 22 ms 35532 KB Output is correct
10 Correct 22 ms 35520 KB Output is correct
11 Correct 21 ms 35500 KB Output is correct
12 Correct 21 ms 35532 KB Output is correct
13 Correct 21 ms 35480 KB Output is correct
14 Correct 21 ms 35524 KB Output is correct
15 Correct 21 ms 35532 KB Output is correct
16 Correct 23 ms 35532 KB Output is correct
17 Correct 21 ms 35532 KB Output is correct
18 Correct 24 ms 35532 KB Output is correct
19 Correct 24 ms 35588 KB Output is correct
20 Correct 24 ms 35532 KB Output is correct
21 Correct 23 ms 35472 KB Output is correct
22 Correct 21 ms 35532 KB Output is correct
23 Correct 21 ms 35444 KB Output is correct
24 Correct 22 ms 35532 KB Output is correct
25 Correct 24 ms 35548 KB Output is correct
26 Correct 21 ms 35488 KB Output is correct
27 Correct 23 ms 35552 KB Output is correct
28 Correct 25 ms 35496 KB Output is correct
29 Correct 25 ms 35456 KB Output is correct
30 Correct 24 ms 35552 KB Output is correct
31 Correct 22 ms 35500 KB Output is correct
32 Correct 21 ms 35548 KB Output is correct
33 Correct 21 ms 35552 KB Output is correct
34 Correct 21 ms 35532 KB Output is correct
35 Correct 21 ms 35532 KB Output is correct
36 Correct 22 ms 35556 KB Output is correct
37 Correct 22 ms 35636 KB Output is correct
38 Correct 23 ms 35556 KB Output is correct
39 Correct 22 ms 35536 KB Output is correct
40 Correct 22 ms 35660 KB Output is correct
41 Correct 21 ms 35556 KB Output is correct
42 Correct 22 ms 35660 KB Output is correct
43 Correct 23 ms 35476 KB Output is correct
44 Correct 22 ms 35504 KB Output is correct
45 Correct 21 ms 35544 KB Output is correct
46 Correct 21 ms 35532 KB Output is correct
47 Correct 21 ms 35532 KB Output is correct
48 Correct 23 ms 35540 KB Output is correct
49 Correct 22 ms 35544 KB Output is correct
50 Correct 23 ms 35448 KB Output is correct
51 Correct 21 ms 35520 KB Output is correct
52 Correct 25 ms 35548 KB Output is correct
53 Correct 21 ms 35532 KB Output is correct
54 Correct 21 ms 35544 KB Output is correct
55 Correct 21 ms 35540 KB Output is correct
56 Correct 21 ms 35536 KB Output is correct
57 Correct 21 ms 35536 KB Output is correct
58 Correct 21 ms 35540 KB Output is correct
59 Correct 21 ms 35508 KB Output is correct
60 Correct 22 ms 35432 KB Output is correct
61 Correct 22 ms 35564 KB Output is correct
62 Correct 22 ms 35480 KB Output is correct
63 Correct 21 ms 35452 KB Output is correct
64 Correct 24 ms 35532 KB Output is correct
65 Correct 20 ms 35532 KB Output is correct
66 Correct 21 ms 35532 KB Output is correct
67 Correct 22 ms 35564 KB Output is correct
68 Correct 43 ms 41588 KB Output is correct
69 Correct 66 ms 47680 KB Output is correct
70 Correct 24 ms 35500 KB Output is correct
71 Correct 91 ms 53952 KB Output is correct
72 Correct 122 ms 60136 KB Output is correct
73 Correct 135 ms 66300 KB Output is correct
74 Correct 163 ms 72476 KB Output is correct
75 Correct 209 ms 78660 KB Output is correct
76 Correct 205 ms 84960 KB Output is correct
77 Correct 260 ms 91092 KB Output is correct
78 Correct 256 ms 97316 KB Output is correct
79 Correct 289 ms 103492 KB Output is correct
80 Correct 313 ms 109616 KB Output is correct
81 Correct 22 ms 35508 KB Output is correct
82 Correct 323 ms 115876 KB Output is correct
83 Correct 358 ms 121948 KB Output is correct
84 Correct 374 ms 128204 KB Output is correct
85 Correct 414 ms 134324 KB Output is correct
86 Correct 437 ms 140472 KB Output is correct
87 Correct 486 ms 146752 KB Output is correct
88 Correct 723 ms 152900 KB Output is correct
89 Correct 869 ms 158936 KB Output is correct
90 Correct 21 ms 35532 KB Output is correct
91 Correct 22 ms 35496 KB Output is correct
92 Correct 21 ms 35500 KB Output is correct
93 Correct 21 ms 35536 KB Output is correct
94 Correct 23 ms 35532 KB Output is correct
95 Correct 21 ms 35548 KB Output is correct
96 Correct 21 ms 35532 KB Output is correct
97 Correct 20 ms 35532 KB Output is correct
98 Correct 22 ms 35532 KB Output is correct
99 Correct 21 ms 35532 KB Output is correct
100 Correct 22 ms 35532 KB Output is correct
101 Correct 22 ms 35532 KB Output is correct
102 Correct 21 ms 35532 KB Output is correct
103 Correct 22 ms 35492 KB Output is correct
104 Correct 21 ms 35532 KB Output is correct
105 Correct 22 ms 35536 KB Output is correct
106 Correct 21 ms 35520 KB Output is correct
107 Correct 21 ms 35532 KB Output is correct
108 Correct 21 ms 35532 KB Output is correct
109 Correct 21 ms 35532 KB Output is correct
110 Correct 21 ms 35512 KB Output is correct
111 Correct 21 ms 35484 KB Output is correct
112 Correct 22 ms 35436 KB Output is correct
113 Correct 22 ms 35544 KB Output is correct
114 Correct 22 ms 35488 KB Output is correct
115 Correct 22 ms 35532 KB Output is correct
116 Correct 24 ms 35516 KB Output is correct
117 Correct 21 ms 35540 KB Output is correct
118 Correct 21 ms 35440 KB Output is correct
119 Correct 22 ms 35532 KB Output is correct
120 Correct 23 ms 35560 KB Output is correct
121 Correct 22 ms 35460 KB Output is correct
122 Correct 21 ms 35532 KB Output is correct
123 Correct 21 ms 35484 KB Output is correct
124 Correct 21 ms 35468 KB Output is correct
125 Correct 21 ms 35552 KB Output is correct
126 Correct 22 ms 35544 KB Output is correct
127 Correct 21 ms 35544 KB Output is correct
128 Correct 22 ms 35532 KB Output is correct
129 Correct 21 ms 35532 KB Output is correct
130 Correct 22 ms 35504 KB Output is correct
131 Correct 21 ms 35556 KB Output is correct
132 Correct 23 ms 35532 KB Output is correct
133 Correct 22 ms 35536 KB Output is correct
134 Correct 22 ms 35532 KB Output is correct
135 Correct 22 ms 35524 KB Output is correct
136 Correct 22 ms 35556 KB Output is correct
137 Correct 21 ms 35652 KB Output is correct
138 Correct 22 ms 35532 KB Output is correct
139 Correct 21 ms 35456 KB Output is correct
140 Correct 22 ms 35516 KB Output is correct
141 Correct 21 ms 35532 KB Output is correct
142 Correct 21 ms 35668 KB Output is correct
143 Correct 21 ms 35472 KB Output is correct
144 Correct 21 ms 35512 KB Output is correct
145 Correct 21 ms 35532 KB Output is correct
146 Correct 21 ms 35536 KB Output is correct
147 Correct 21 ms 35532 KB Output is correct
148 Correct 22 ms 35536 KB Output is correct
149 Correct 22 ms 35548 KB Output is correct
150 Correct 21 ms 35532 KB Output is correct
151 Correct 22 ms 35552 KB Output is correct
152 Correct 22 ms 35520 KB Output is correct
153 Correct 21 ms 35532 KB Output is correct
154 Correct 21 ms 35544 KB Output is correct
155 Correct 21 ms 35516 KB Output is correct
156 Correct 21 ms 35532 KB Output is correct
157 Correct 21 ms 35532 KB Output is correct
158 Correct 21 ms 35532 KB Output is correct
159 Correct 21 ms 35532 KB Output is correct
160 Correct 21 ms 35468 KB Output is correct
161 Correct 22 ms 35488 KB Output is correct
162 Correct 22 ms 35532 KB Output is correct
163 Correct 22 ms 35472 KB Output is correct
164 Correct 21 ms 35532 KB Output is correct
165 Correct 21 ms 35532 KB Output is correct
166 Correct 21 ms 35456 KB Output is correct
167 Correct 21 ms 35536 KB Output is correct
168 Correct 22 ms 35508 KB Output is correct
169 Correct 22 ms 35544 KB Output is correct
170 Correct 22 ms 35532 KB Output is correct
171 Correct 51 ms 38584 KB Output is correct
172 Correct 80 ms 41484 KB Output is correct
173 Correct 138 ms 44740 KB Output is correct
174 Correct 193 ms 47704 KB Output is correct
175 Correct 260 ms 50844 KB Output is correct
176 Correct 325 ms 53900 KB Output is correct
177 Correct 389 ms 56976 KB Output is correct
178 Correct 447 ms 60048 KB Output is correct
179 Correct 509 ms 63300 KB Output is correct
180 Correct 22 ms 35532 KB Output is correct
181 Correct 549 ms 66244 KB Output is correct
182 Correct 626 ms 69728 KB Output is correct
183 Correct 734 ms 72424 KB Output is correct
184 Correct 769 ms 75588 KB Output is correct
185 Correct 846 ms 78660 KB Output is correct
186 Correct 992 ms 81756 KB Output is correct
187 Correct 1154 ms 84668 KB Output is correct
188 Correct 1332 ms 87860 KB Output is correct
189 Correct 1111 ms 90840 KB Output is correct
190 Correct 1234 ms 94020 KB Output is correct
191 Correct 21 ms 35536 KB Output is correct
192 Correct 1651 ms 96940 KB Output is correct
193 Correct 342 ms 95936 KB Output is correct
194 Correct 670 ms 156704 KB Output is correct
195 Correct 21 ms 35532 KB Output is correct
196 Correct 22 ms 35468 KB Output is correct
197 Correct 22 ms 35532 KB Output is correct
198 Correct 21 ms 35536 KB Output is correct