Submission #411597

# Submission time Handle Problem Language Result Execution time Memory
411597 2021-05-25T14:56:19 Z nishachar_coder Traffic (IOI10_traffic) C++14
100 / 100
1153 ms 158892 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 21 ms 35524 KB Output is correct
2 Correct 22 ms 35532 KB Output is correct
3 Correct 22 ms 35540 KB Output is correct
4 Correct 22 ms 35536 KB Output is correct
5 Correct 22 ms 35532 KB Output is correct
6 Correct 22 ms 35512 KB Output is correct
7 Correct 22 ms 35532 KB Output is correct
8 Correct 22 ms 35516 KB Output is correct
9 Correct 22 ms 35536 KB Output is correct
10 Correct 24 ms 35516 KB Output is correct
11 Correct 22 ms 35468 KB Output is correct
12 Correct 22 ms 35540 KB Output is correct
13 Correct 22 ms 35532 KB Output is correct
14 Correct 22 ms 35540 KB Output is correct
15 Correct 22 ms 35540 KB Output is correct
16 Correct 23 ms 35532 KB Output is correct
17 Correct 22 ms 35544 KB Output is correct
18 Correct 22 ms 35536 KB Output is correct
19 Correct 21 ms 35532 KB Output is correct
20 Correct 22 ms 35536 KB Output is correct
21 Correct 22 ms 35480 KB Output is correct
22 Correct 22 ms 35532 KB Output is correct
23 Correct 22 ms 35452 KB Output is correct
24 Correct 22 ms 35528 KB Output is correct
25 Correct 22 ms 35488 KB Output is correct
26 Correct 23 ms 35524 KB Output is correct
27 Correct 24 ms 35492 KB Output is correct
28 Correct 21 ms 35552 KB Output is correct
29 Correct 22 ms 35496 KB Output is correct
30 Correct 22 ms 35580 KB Output is correct
31 Correct 22 ms 35568 KB Output is correct
32 Correct 22 ms 35500 KB Output is correct
33 Correct 22 ms 35544 KB Output is correct
34 Correct 22 ms 35468 KB Output is correct
35 Correct 23 ms 35628 KB Output is correct
36 Correct 23 ms 35640 KB Output is correct
37 Correct 25 ms 35520 KB Output is correct
38 Correct 22 ms 35548 KB Output is correct
39 Correct 25 ms 35608 KB Output is correct
40 Correct 22 ms 35660 KB Output is correct
41 Correct 22 ms 35632 KB Output is correct
42 Correct 23 ms 35648 KB Output is correct
43 Correct 23 ms 35532 KB Output is correct
44 Correct 22 ms 35532 KB Output is correct
45 Correct 22 ms 35468 KB Output is correct
46 Correct 22 ms 35532 KB Output is correct
47 Correct 22 ms 35532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 35524 KB Output is correct
2 Correct 22 ms 35532 KB Output is correct
3 Correct 22 ms 35540 KB Output is correct
4 Correct 22 ms 35536 KB Output is correct
5 Correct 22 ms 35532 KB Output is correct
6 Correct 22 ms 35512 KB Output is correct
7 Correct 22 ms 35532 KB Output is correct
8 Correct 22 ms 35516 KB Output is correct
9 Correct 22 ms 35536 KB Output is correct
10 Correct 24 ms 35516 KB Output is correct
11 Correct 22 ms 35468 KB Output is correct
12 Correct 22 ms 35540 KB Output is correct
13 Correct 22 ms 35532 KB Output is correct
14 Correct 22 ms 35540 KB Output is correct
15 Correct 22 ms 35540 KB Output is correct
16 Correct 23 ms 35532 KB Output is correct
17 Correct 22 ms 35544 KB Output is correct
18 Correct 22 ms 35536 KB Output is correct
19 Correct 21 ms 35532 KB Output is correct
20 Correct 22 ms 35536 KB Output is correct
21 Correct 22 ms 35480 KB Output is correct
22 Correct 22 ms 35532 KB Output is correct
23 Correct 22 ms 35452 KB Output is correct
24 Correct 22 ms 35528 KB Output is correct
25 Correct 22 ms 35488 KB Output is correct
26 Correct 23 ms 35524 KB Output is correct
27 Correct 24 ms 35492 KB Output is correct
28 Correct 21 ms 35552 KB Output is correct
29 Correct 22 ms 35496 KB Output is correct
30 Correct 22 ms 35580 KB Output is correct
31 Correct 22 ms 35568 KB Output is correct
32 Correct 22 ms 35500 KB Output is correct
33 Correct 22 ms 35544 KB Output is correct
34 Correct 22 ms 35468 KB Output is correct
35 Correct 23 ms 35628 KB Output is correct
36 Correct 23 ms 35640 KB Output is correct
37 Correct 25 ms 35520 KB Output is correct
38 Correct 22 ms 35548 KB Output is correct
39 Correct 25 ms 35608 KB Output is correct
40 Correct 22 ms 35660 KB Output is correct
41 Correct 22 ms 35632 KB Output is correct
42 Correct 23 ms 35648 KB Output is correct
43 Correct 23 ms 35532 KB Output is correct
44 Correct 22 ms 35532 KB Output is correct
45 Correct 22 ms 35468 KB Output is correct
46 Correct 22 ms 35532 KB Output is correct
47 Correct 22 ms 35532 KB Output is correct
48 Correct 22 ms 35544 KB Output is correct
49 Correct 22 ms 35544 KB Output is correct
50 Correct 21 ms 35544 KB Output is correct
51 Correct 22 ms 35536 KB Output is correct
52 Correct 22 ms 35440 KB Output is correct
53 Correct 23 ms 35432 KB Output is correct
54 Correct 22 ms 35536 KB Output is correct
55 Correct 22 ms 35496 KB Output is correct
56 Correct 22 ms 35500 KB Output is correct
57 Correct 22 ms 35536 KB Output is correct
58 Correct 22 ms 35516 KB Output is correct
59 Correct 20 ms 35488 KB Output is correct
60 Correct 22 ms 35564 KB Output is correct
61 Correct 22 ms 35512 KB Output is correct
62 Correct 22 ms 35532 KB Output is correct
63 Correct 23 ms 35532 KB Output is correct
64 Correct 22 ms 35532 KB Output is correct
65 Correct 22 ms 35520 KB Output is correct
66 Correct 22 ms 35536 KB Output is correct
67 Correct 22 ms 35532 KB Output is correct
68 Correct 45 ms 41668 KB Output is correct
69 Correct 69 ms 47684 KB Output is correct
70 Correct 22 ms 35532 KB Output is correct
71 Correct 94 ms 53896 KB Output is correct
72 Correct 121 ms 60088 KB Output is correct
73 Correct 144 ms 66244 KB Output is correct
74 Correct 167 ms 72508 KB Output is correct
75 Correct 194 ms 78724 KB Output is correct
76 Correct 213 ms 84860 KB Output is correct
77 Correct 239 ms 91076 KB Output is correct
78 Correct 293 ms 97368 KB Output is correct
79 Correct 290 ms 103432 KB Output is correct
80 Correct 326 ms 109560 KB Output is correct
81 Correct 22 ms 35532 KB Output is correct
82 Correct 335 ms 115768 KB Output is correct
83 Correct 362 ms 121932 KB Output is correct
84 Correct 426 ms 128108 KB Output is correct
85 Correct 422 ms 134400 KB Output is correct
86 Correct 456 ms 140484 KB Output is correct
87 Correct 470 ms 146628 KB Output is correct
88 Correct 535 ms 152864 KB Output is correct
89 Correct 503 ms 158892 KB Output is correct
90 Correct 21 ms 35532 KB Output is correct
91 Correct 22 ms 35544 KB Output is correct
92 Correct 22 ms 35452 KB Output is correct
93 Correct 22 ms 35496 KB Output is correct
94 Correct 24 ms 35452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 35524 KB Output is correct
2 Correct 22 ms 35532 KB Output is correct
3 Correct 22 ms 35540 KB Output is correct
4 Correct 22 ms 35536 KB Output is correct
5 Correct 22 ms 35532 KB Output is correct
6 Correct 22 ms 35512 KB Output is correct
7 Correct 22 ms 35532 KB Output is correct
8 Correct 22 ms 35516 KB Output is correct
9 Correct 22 ms 35536 KB Output is correct
10 Correct 24 ms 35516 KB Output is correct
11 Correct 22 ms 35468 KB Output is correct
12 Correct 22 ms 35540 KB Output is correct
13 Correct 22 ms 35532 KB Output is correct
14 Correct 22 ms 35540 KB Output is correct
15 Correct 22 ms 35540 KB Output is correct
16 Correct 23 ms 35532 KB Output is correct
17 Correct 22 ms 35544 KB Output is correct
18 Correct 22 ms 35536 KB Output is correct
19 Correct 21 ms 35532 KB Output is correct
20 Correct 22 ms 35536 KB Output is correct
21 Correct 22 ms 35480 KB Output is correct
22 Correct 22 ms 35532 KB Output is correct
23 Correct 22 ms 35452 KB Output is correct
24 Correct 22 ms 35528 KB Output is correct
25 Correct 22 ms 35488 KB Output is correct
26 Correct 23 ms 35524 KB Output is correct
27 Correct 24 ms 35492 KB Output is correct
28 Correct 21 ms 35552 KB Output is correct
29 Correct 22 ms 35496 KB Output is correct
30 Correct 22 ms 35580 KB Output is correct
31 Correct 22 ms 35568 KB Output is correct
32 Correct 22 ms 35500 KB Output is correct
33 Correct 22 ms 35544 KB Output is correct
34 Correct 22 ms 35468 KB Output is correct
35 Correct 23 ms 35628 KB Output is correct
36 Correct 23 ms 35640 KB Output is correct
37 Correct 25 ms 35520 KB Output is correct
38 Correct 22 ms 35548 KB Output is correct
39 Correct 25 ms 35608 KB Output is correct
40 Correct 22 ms 35660 KB Output is correct
41 Correct 22 ms 35632 KB Output is correct
42 Correct 23 ms 35648 KB Output is correct
43 Correct 23 ms 35532 KB Output is correct
44 Correct 22 ms 35532 KB Output is correct
45 Correct 22 ms 35468 KB Output is correct
46 Correct 22 ms 35532 KB Output is correct
47 Correct 22 ms 35532 KB Output is correct
48 Correct 21 ms 35520 KB Output is correct
49 Correct 22 ms 35464 KB Output is correct
50 Correct 22 ms 35544 KB Output is correct
51 Correct 22 ms 35532 KB Output is correct
52 Correct 21 ms 35524 KB Output is correct
53 Correct 22 ms 35532 KB Output is correct
54 Correct 21 ms 35500 KB Output is correct
55 Correct 22 ms 35532 KB Output is correct
56 Correct 22 ms 35540 KB Output is correct
57 Correct 22 ms 35480 KB Output is correct
58 Correct 22 ms 35660 KB Output is correct
59 Correct 21 ms 35488 KB Output is correct
60 Correct 22 ms 35500 KB Output is correct
61 Correct 21 ms 35492 KB Output is correct
62 Correct 22 ms 35532 KB Output is correct
63 Correct 22 ms 35532 KB Output is correct
64 Correct 22 ms 35448 KB Output is correct
65 Correct 22 ms 35488 KB Output is correct
66 Correct 21 ms 35456 KB Output is correct
67 Correct 20 ms 35476 KB Output is correct
68 Correct 21 ms 35472 KB Output is correct
69 Correct 23 ms 35488 KB Output is correct
70 Correct 23 ms 35452 KB Output is correct
71 Correct 23 ms 35516 KB Output is correct
72 Correct 22 ms 35452 KB Output is correct
73 Correct 22 ms 35484 KB Output is correct
74 Correct 22 ms 35500 KB Output is correct
75 Correct 22 ms 35556 KB Output is correct
76 Correct 22 ms 35556 KB Output is correct
77 Correct 23 ms 35544 KB Output is correct
78 Correct 21 ms 35532 KB Output is correct
79 Correct 22 ms 35532 KB Output is correct
80 Correct 22 ms 35576 KB Output is correct
81 Correct 24 ms 35516 KB Output is correct
82 Correct 22 ms 35532 KB Output is correct
83 Correct 22 ms 35548 KB Output is correct
84 Correct 22 ms 35556 KB Output is correct
85 Correct 23 ms 35548 KB Output is correct
86 Correct 24 ms 35508 KB Output is correct
87 Correct 22 ms 35604 KB Output is correct
88 Correct 22 ms 35552 KB Output is correct
89 Correct 22 ms 35532 KB Output is correct
90 Correct 23 ms 35592 KB Output is correct
91 Correct 22 ms 35552 KB Output is correct
92 Correct 21 ms 35528 KB Output is correct
93 Correct 23 ms 35528 KB Output is correct
94 Correct 23 ms 35532 KB Output is correct
95 Correct 25 ms 35628 KB Output is correct
96 Correct 22 ms 35532 KB Output is correct
97 Correct 22 ms 35440 KB Output is correct
98 Correct 21 ms 35464 KB Output is correct
99 Correct 24 ms 35532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 35524 KB Output is correct
2 Correct 22 ms 35532 KB Output is correct
3 Correct 22 ms 35540 KB Output is correct
4 Correct 22 ms 35536 KB Output is correct
5 Correct 22 ms 35532 KB Output is correct
6 Correct 22 ms 35512 KB Output is correct
7 Correct 22 ms 35532 KB Output is correct
8 Correct 22 ms 35516 KB Output is correct
9 Correct 22 ms 35536 KB Output is correct
10 Correct 24 ms 35516 KB Output is correct
11 Correct 22 ms 35468 KB Output is correct
12 Correct 22 ms 35540 KB Output is correct
13 Correct 22 ms 35532 KB Output is correct
14 Correct 22 ms 35540 KB Output is correct
15 Correct 22 ms 35540 KB Output is correct
16 Correct 23 ms 35532 KB Output is correct
17 Correct 22 ms 35544 KB Output is correct
18 Correct 22 ms 35536 KB Output is correct
19 Correct 21 ms 35532 KB Output is correct
20 Correct 22 ms 35536 KB Output is correct
21 Correct 22 ms 35480 KB Output is correct
22 Correct 22 ms 35532 KB Output is correct
23 Correct 22 ms 35452 KB Output is correct
24 Correct 22 ms 35528 KB Output is correct
25 Correct 22 ms 35488 KB Output is correct
26 Correct 23 ms 35524 KB Output is correct
27 Correct 24 ms 35492 KB Output is correct
28 Correct 21 ms 35552 KB Output is correct
29 Correct 22 ms 35496 KB Output is correct
30 Correct 22 ms 35580 KB Output is correct
31 Correct 22 ms 35568 KB Output is correct
32 Correct 22 ms 35500 KB Output is correct
33 Correct 22 ms 35544 KB Output is correct
34 Correct 22 ms 35468 KB Output is correct
35 Correct 23 ms 35628 KB Output is correct
36 Correct 23 ms 35640 KB Output is correct
37 Correct 25 ms 35520 KB Output is correct
38 Correct 22 ms 35548 KB Output is correct
39 Correct 25 ms 35608 KB Output is correct
40 Correct 22 ms 35660 KB Output is correct
41 Correct 22 ms 35632 KB Output is correct
42 Correct 23 ms 35648 KB Output is correct
43 Correct 23 ms 35532 KB Output is correct
44 Correct 22 ms 35532 KB Output is correct
45 Correct 22 ms 35468 KB Output is correct
46 Correct 22 ms 35532 KB Output is correct
47 Correct 22 ms 35532 KB Output is correct
48 Correct 22 ms 35544 KB Output is correct
49 Correct 22 ms 35544 KB Output is correct
50 Correct 21 ms 35544 KB Output is correct
51 Correct 22 ms 35536 KB Output is correct
52 Correct 22 ms 35440 KB Output is correct
53 Correct 23 ms 35432 KB Output is correct
54 Correct 22 ms 35536 KB Output is correct
55 Correct 22 ms 35496 KB Output is correct
56 Correct 22 ms 35500 KB Output is correct
57 Correct 22 ms 35536 KB Output is correct
58 Correct 22 ms 35516 KB Output is correct
59 Correct 20 ms 35488 KB Output is correct
60 Correct 22 ms 35564 KB Output is correct
61 Correct 22 ms 35512 KB Output is correct
62 Correct 22 ms 35532 KB Output is correct
63 Correct 23 ms 35532 KB Output is correct
64 Correct 22 ms 35532 KB Output is correct
65 Correct 22 ms 35520 KB Output is correct
66 Correct 22 ms 35536 KB Output is correct
67 Correct 22 ms 35532 KB Output is correct
68 Correct 45 ms 41668 KB Output is correct
69 Correct 69 ms 47684 KB Output is correct
70 Correct 22 ms 35532 KB Output is correct
71 Correct 94 ms 53896 KB Output is correct
72 Correct 121 ms 60088 KB Output is correct
73 Correct 144 ms 66244 KB Output is correct
74 Correct 167 ms 72508 KB Output is correct
75 Correct 194 ms 78724 KB Output is correct
76 Correct 213 ms 84860 KB Output is correct
77 Correct 239 ms 91076 KB Output is correct
78 Correct 293 ms 97368 KB Output is correct
79 Correct 290 ms 103432 KB Output is correct
80 Correct 326 ms 109560 KB Output is correct
81 Correct 22 ms 35532 KB Output is correct
82 Correct 335 ms 115768 KB Output is correct
83 Correct 362 ms 121932 KB Output is correct
84 Correct 426 ms 128108 KB Output is correct
85 Correct 422 ms 134400 KB Output is correct
86 Correct 456 ms 140484 KB Output is correct
87 Correct 470 ms 146628 KB Output is correct
88 Correct 535 ms 152864 KB Output is correct
89 Correct 503 ms 158892 KB Output is correct
90 Correct 21 ms 35532 KB Output is correct
91 Correct 22 ms 35544 KB Output is correct
92 Correct 22 ms 35452 KB Output is correct
93 Correct 22 ms 35496 KB Output is correct
94 Correct 24 ms 35452 KB Output is correct
95 Correct 21 ms 35520 KB Output is correct
96 Correct 22 ms 35464 KB Output is correct
97 Correct 22 ms 35544 KB Output is correct
98 Correct 22 ms 35532 KB Output is correct
99 Correct 21 ms 35524 KB Output is correct
100 Correct 22 ms 35532 KB Output is correct
101 Correct 21 ms 35500 KB Output is correct
102 Correct 22 ms 35532 KB Output is correct
103 Correct 22 ms 35540 KB Output is correct
104 Correct 22 ms 35480 KB Output is correct
105 Correct 22 ms 35660 KB Output is correct
106 Correct 21 ms 35488 KB Output is correct
107 Correct 22 ms 35500 KB Output is correct
108 Correct 21 ms 35492 KB Output is correct
109 Correct 22 ms 35532 KB Output is correct
110 Correct 22 ms 35532 KB Output is correct
111 Correct 22 ms 35448 KB Output is correct
112 Correct 22 ms 35488 KB Output is correct
113 Correct 21 ms 35456 KB Output is correct
114 Correct 20 ms 35476 KB Output is correct
115 Correct 21 ms 35472 KB Output is correct
116 Correct 23 ms 35488 KB Output is correct
117 Correct 23 ms 35452 KB Output is correct
118 Correct 23 ms 35516 KB Output is correct
119 Correct 22 ms 35452 KB Output is correct
120 Correct 22 ms 35484 KB Output is correct
121 Correct 22 ms 35500 KB Output is correct
122 Correct 22 ms 35556 KB Output is correct
123 Correct 22 ms 35556 KB Output is correct
124 Correct 23 ms 35544 KB Output is correct
125 Correct 21 ms 35532 KB Output is correct
126 Correct 22 ms 35532 KB Output is correct
127 Correct 22 ms 35576 KB Output is correct
128 Correct 24 ms 35516 KB Output is correct
129 Correct 22 ms 35532 KB Output is correct
130 Correct 22 ms 35548 KB Output is correct
131 Correct 22 ms 35556 KB Output is correct
132 Correct 23 ms 35548 KB Output is correct
133 Correct 24 ms 35508 KB Output is correct
134 Correct 22 ms 35604 KB Output is correct
135 Correct 22 ms 35552 KB Output is correct
136 Correct 22 ms 35532 KB Output is correct
137 Correct 23 ms 35592 KB Output is correct
138 Correct 22 ms 35552 KB Output is correct
139 Correct 21 ms 35528 KB Output is correct
140 Correct 23 ms 35528 KB Output is correct
141 Correct 23 ms 35532 KB Output is correct
142 Correct 25 ms 35628 KB Output is correct
143 Correct 22 ms 35532 KB Output is correct
144 Correct 22 ms 35440 KB Output is correct
145 Correct 21 ms 35464 KB Output is correct
146 Correct 24 ms 35532 KB Output is correct
147 Correct 25 ms 35532 KB Output is correct
148 Correct 22 ms 35484 KB Output is correct
149 Correct 23 ms 35552 KB Output is correct
150 Correct 25 ms 35540 KB Output is correct
151 Correct 23 ms 35544 KB Output is correct
152 Correct 22 ms 35500 KB Output is correct
153 Correct 21 ms 35544 KB Output is correct
154 Correct 22 ms 35532 KB Output is correct
155 Correct 22 ms 35456 KB Output is correct
156 Correct 22 ms 35560 KB Output is correct
157 Correct 22 ms 35544 KB Output is correct
158 Correct 21 ms 35544 KB Output is correct
159 Correct 21 ms 35532 KB Output is correct
160 Correct 22 ms 35524 KB Output is correct
161 Correct 23 ms 35532 KB Output is correct
162 Correct 22 ms 35532 KB Output is correct
163 Correct 22 ms 35532 KB Output is correct
164 Correct 21 ms 35532 KB Output is correct
165 Correct 21 ms 35544 KB Output is correct
166 Correct 22 ms 35532 KB Output is correct
167 Correct 22 ms 35500 KB Output is correct
168 Correct 22 ms 35540 KB Output is correct
169 Correct 21 ms 35444 KB Output is correct
170 Correct 22 ms 35496 KB Output is correct
171 Correct 51 ms 38468 KB Output is correct
172 Correct 91 ms 41540 KB Output is correct
173 Correct 132 ms 44660 KB Output is correct
174 Correct 188 ms 47744 KB Output is correct
175 Correct 245 ms 50828 KB Output is correct
176 Correct 327 ms 53884 KB Output is correct
177 Correct 354 ms 56960 KB Output is correct
178 Correct 435 ms 60080 KB Output is correct
179 Correct 472 ms 63172 KB Output is correct
180 Correct 24 ms 35532 KB Output is correct
181 Correct 555 ms 66208 KB Output is correct
182 Correct 616 ms 69212 KB Output is correct
183 Correct 679 ms 72376 KB Output is correct
184 Correct 770 ms 75484 KB Output is correct
185 Correct 789 ms 78516 KB Output is correct
186 Correct 856 ms 81604 KB Output is correct
187 Correct 930 ms 84672 KB Output is correct
188 Correct 990 ms 87620 KB Output is correct
189 Correct 1034 ms 90756 KB Output is correct
190 Correct 1095 ms 93872 KB Output is correct
191 Correct 22 ms 35532 KB Output is correct
192 Correct 1153 ms 96776 KB Output is correct
193 Correct 245 ms 96068 KB Output is correct
194 Correct 514 ms 156484 KB Output is correct
195 Correct 21 ms 35532 KB Output is correct
196 Correct 20 ms 35532 KB Output is correct
197 Correct 20 ms 35632 KB Output is correct
198 Correct 21 ms 35524 KB Output is correct