# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
373952 |
2021-03-06T09:27:18 Z |
duchung |
Race (IOI11_race) |
C++17 |
|
522 ms |
89708 KB |
#define ii pair<int , int>
#include <race.h>
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int _k , ans = 1e9;
int dist[N] , depth[N];
vector<ii> adj[N];
set<ii> S[N];
void dfs(int u , int p = -1)
{
S[u].insert(make_pair(dist[u] , depth[u]));
for (auto e : adj[u])
{
int v = e.first;
int w = e.second;
if (v == p) continue;
dist[v] = dist[u] + w;
depth[v] = depth[u] + 1;
dfs(v , u);
if (S[u].size() < S[v].size()) swap(S[u] , S[v]);
for (auto x : S[v])
{
auto it = S[u].lower_bound(make_pair(_k - x.first + 2 * dist[u] , 0));
if (it != S[u].end() && it->first + x.first - 2 * dist[u] == _k) ans = min(ans , it->second + x.second - 2 * depth[u]);
}
for (auto x : S[v])
{
S[u].insert(x);
}
}
}
int best_path(int n, int k, int H[][2], int L[]) {
_k = k;
for (int i = 0; i < n - 1; i++) {
++H[i][0] , ++H[i][1];
adj[H[i][0]].push_back(make_pair(H[i][1], L[i]));
adj[H[i][1]].push_back(make_pair(H[i][0], L[i]));
}
dfs(1);
return (ans == 1e9 ? -1 : ans);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
14444 KB |
Output is correct |
2 |
Correct |
10 ms |
14444 KB |
Output is correct |
3 |
Correct |
11 ms |
14444 KB |
Output is correct |
4 |
Correct |
11 ms |
14444 KB |
Output is correct |
5 |
Correct |
10 ms |
14444 KB |
Output is correct |
6 |
Correct |
10 ms |
14444 KB |
Output is correct |
7 |
Correct |
10 ms |
14488 KB |
Output is correct |
8 |
Correct |
10 ms |
14444 KB |
Output is correct |
9 |
Correct |
10 ms |
14444 KB |
Output is correct |
10 |
Correct |
10 ms |
14444 KB |
Output is correct |
11 |
Correct |
10 ms |
14444 KB |
Output is correct |
12 |
Correct |
10 ms |
14588 KB |
Output is correct |
13 |
Correct |
10 ms |
14444 KB |
Output is correct |
14 |
Correct |
10 ms |
14444 KB |
Output is correct |
15 |
Correct |
11 ms |
14476 KB |
Output is correct |
16 |
Correct |
10 ms |
14444 KB |
Output is correct |
17 |
Correct |
11 ms |
14444 KB |
Output is correct |
18 |
Correct |
10 ms |
14444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
14444 KB |
Output is correct |
2 |
Correct |
10 ms |
14444 KB |
Output is correct |
3 |
Correct |
11 ms |
14444 KB |
Output is correct |
4 |
Correct |
11 ms |
14444 KB |
Output is correct |
5 |
Correct |
10 ms |
14444 KB |
Output is correct |
6 |
Correct |
10 ms |
14444 KB |
Output is correct |
7 |
Correct |
10 ms |
14488 KB |
Output is correct |
8 |
Correct |
10 ms |
14444 KB |
Output is correct |
9 |
Correct |
10 ms |
14444 KB |
Output is correct |
10 |
Correct |
10 ms |
14444 KB |
Output is correct |
11 |
Correct |
10 ms |
14444 KB |
Output is correct |
12 |
Correct |
10 ms |
14588 KB |
Output is correct |
13 |
Correct |
10 ms |
14444 KB |
Output is correct |
14 |
Correct |
10 ms |
14444 KB |
Output is correct |
15 |
Correct |
11 ms |
14476 KB |
Output is correct |
16 |
Correct |
10 ms |
14444 KB |
Output is correct |
17 |
Correct |
11 ms |
14444 KB |
Output is correct |
18 |
Correct |
10 ms |
14444 KB |
Output is correct |
19 |
Correct |
10 ms |
14444 KB |
Output is correct |
20 |
Correct |
10 ms |
14444 KB |
Output is correct |
21 |
Correct |
13 ms |
14700 KB |
Output is correct |
22 |
Correct |
11 ms |
14700 KB |
Output is correct |
23 |
Correct |
11 ms |
14700 KB |
Output is correct |
24 |
Correct |
11 ms |
14700 KB |
Output is correct |
25 |
Correct |
11 ms |
14700 KB |
Output is correct |
26 |
Correct |
13 ms |
14700 KB |
Output is correct |
27 |
Correct |
11 ms |
14572 KB |
Output is correct |
28 |
Correct |
11 ms |
14700 KB |
Output is correct |
29 |
Correct |
11 ms |
14700 KB |
Output is correct |
30 |
Correct |
11 ms |
14700 KB |
Output is correct |
31 |
Correct |
11 ms |
14700 KB |
Output is correct |
32 |
Correct |
11 ms |
14700 KB |
Output is correct |
33 |
Correct |
11 ms |
14700 KB |
Output is correct |
34 |
Correct |
11 ms |
14700 KB |
Output is correct |
35 |
Correct |
11 ms |
14700 KB |
Output is correct |
36 |
Correct |
11 ms |
14700 KB |
Output is correct |
37 |
Correct |
12 ms |
14572 KB |
Output is correct |
38 |
Correct |
13 ms |
14700 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
14444 KB |
Output is correct |
2 |
Correct |
10 ms |
14444 KB |
Output is correct |
3 |
Correct |
11 ms |
14444 KB |
Output is correct |
4 |
Correct |
11 ms |
14444 KB |
Output is correct |
5 |
Correct |
10 ms |
14444 KB |
Output is correct |
6 |
Correct |
10 ms |
14444 KB |
Output is correct |
7 |
Correct |
10 ms |
14488 KB |
Output is correct |
8 |
Correct |
10 ms |
14444 KB |
Output is correct |
9 |
Correct |
10 ms |
14444 KB |
Output is correct |
10 |
Correct |
10 ms |
14444 KB |
Output is correct |
11 |
Correct |
10 ms |
14444 KB |
Output is correct |
12 |
Correct |
10 ms |
14588 KB |
Output is correct |
13 |
Correct |
10 ms |
14444 KB |
Output is correct |
14 |
Correct |
10 ms |
14444 KB |
Output is correct |
15 |
Correct |
11 ms |
14476 KB |
Output is correct |
16 |
Correct |
10 ms |
14444 KB |
Output is correct |
17 |
Correct |
11 ms |
14444 KB |
Output is correct |
18 |
Correct |
10 ms |
14444 KB |
Output is correct |
19 |
Correct |
185 ms |
36844 KB |
Output is correct |
20 |
Correct |
206 ms |
36840 KB |
Output is correct |
21 |
Correct |
187 ms |
36332 KB |
Output is correct |
22 |
Correct |
181 ms |
35308 KB |
Output is correct |
23 |
Correct |
202 ms |
46188 KB |
Output is correct |
24 |
Correct |
179 ms |
36076 KB |
Output is correct |
25 |
Correct |
173 ms |
40736 KB |
Output is correct |
26 |
Correct |
119 ms |
45932 KB |
Output is correct |
27 |
Correct |
252 ms |
45420 KB |
Output is correct |
28 |
Correct |
326 ms |
77676 KB |
Output is correct |
29 |
Correct |
350 ms |
76140 KB |
Output is correct |
30 |
Correct |
251 ms |
45548 KB |
Output is correct |
31 |
Correct |
279 ms |
45548 KB |
Output is correct |
32 |
Correct |
364 ms |
45784 KB |
Output is correct |
33 |
Correct |
297 ms |
46880 KB |
Output is correct |
34 |
Correct |
389 ms |
71532 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
14444 KB |
Output is correct |
2 |
Correct |
10 ms |
14444 KB |
Output is correct |
3 |
Correct |
11 ms |
14444 KB |
Output is correct |
4 |
Correct |
11 ms |
14444 KB |
Output is correct |
5 |
Correct |
10 ms |
14444 KB |
Output is correct |
6 |
Correct |
10 ms |
14444 KB |
Output is correct |
7 |
Correct |
10 ms |
14488 KB |
Output is correct |
8 |
Correct |
10 ms |
14444 KB |
Output is correct |
9 |
Correct |
10 ms |
14444 KB |
Output is correct |
10 |
Correct |
10 ms |
14444 KB |
Output is correct |
11 |
Correct |
10 ms |
14444 KB |
Output is correct |
12 |
Correct |
10 ms |
14588 KB |
Output is correct |
13 |
Correct |
10 ms |
14444 KB |
Output is correct |
14 |
Correct |
10 ms |
14444 KB |
Output is correct |
15 |
Correct |
11 ms |
14476 KB |
Output is correct |
16 |
Correct |
10 ms |
14444 KB |
Output is correct |
17 |
Correct |
11 ms |
14444 KB |
Output is correct |
18 |
Correct |
10 ms |
14444 KB |
Output is correct |
19 |
Correct |
10 ms |
14444 KB |
Output is correct |
20 |
Correct |
10 ms |
14444 KB |
Output is correct |
21 |
Correct |
13 ms |
14700 KB |
Output is correct |
22 |
Correct |
11 ms |
14700 KB |
Output is correct |
23 |
Correct |
11 ms |
14700 KB |
Output is correct |
24 |
Correct |
11 ms |
14700 KB |
Output is correct |
25 |
Correct |
11 ms |
14700 KB |
Output is correct |
26 |
Correct |
13 ms |
14700 KB |
Output is correct |
27 |
Correct |
11 ms |
14572 KB |
Output is correct |
28 |
Correct |
11 ms |
14700 KB |
Output is correct |
29 |
Correct |
11 ms |
14700 KB |
Output is correct |
30 |
Correct |
11 ms |
14700 KB |
Output is correct |
31 |
Correct |
11 ms |
14700 KB |
Output is correct |
32 |
Correct |
11 ms |
14700 KB |
Output is correct |
33 |
Correct |
11 ms |
14700 KB |
Output is correct |
34 |
Correct |
11 ms |
14700 KB |
Output is correct |
35 |
Correct |
11 ms |
14700 KB |
Output is correct |
36 |
Correct |
11 ms |
14700 KB |
Output is correct |
37 |
Correct |
12 ms |
14572 KB |
Output is correct |
38 |
Correct |
13 ms |
14700 KB |
Output is correct |
39 |
Correct |
185 ms |
36844 KB |
Output is correct |
40 |
Correct |
206 ms |
36840 KB |
Output is correct |
41 |
Correct |
187 ms |
36332 KB |
Output is correct |
42 |
Correct |
181 ms |
35308 KB |
Output is correct |
43 |
Correct |
202 ms |
46188 KB |
Output is correct |
44 |
Correct |
179 ms |
36076 KB |
Output is correct |
45 |
Correct |
173 ms |
40736 KB |
Output is correct |
46 |
Correct |
119 ms |
45932 KB |
Output is correct |
47 |
Correct |
252 ms |
45420 KB |
Output is correct |
48 |
Correct |
326 ms |
77676 KB |
Output is correct |
49 |
Correct |
350 ms |
76140 KB |
Output is correct |
50 |
Correct |
251 ms |
45548 KB |
Output is correct |
51 |
Correct |
279 ms |
45548 KB |
Output is correct |
52 |
Correct |
364 ms |
45784 KB |
Output is correct |
53 |
Correct |
297 ms |
46880 KB |
Output is correct |
54 |
Correct |
389 ms |
71532 KB |
Output is correct |
55 |
Correct |
25 ms |
17132 KB |
Output is correct |
56 |
Correct |
26 ms |
16236 KB |
Output is correct |
57 |
Correct |
121 ms |
33024 KB |
Output is correct |
58 |
Correct |
63 ms |
26136 KB |
Output is correct |
59 |
Correct |
121 ms |
45920 KB |
Output is correct |
60 |
Correct |
362 ms |
76664 KB |
Output is correct |
61 |
Correct |
293 ms |
50028 KB |
Output is correct |
62 |
Correct |
254 ms |
45548 KB |
Output is correct |
63 |
Correct |
418 ms |
45580 KB |
Output is correct |
64 |
Correct |
522 ms |
89708 KB |
Output is correct |
65 |
Correct |
518 ms |
83564 KB |
Output is correct |
66 |
Correct |
355 ms |
72812 KB |
Output is correct |
67 |
Correct |
252 ms |
39228 KB |
Output is correct |
68 |
Correct |
465 ms |
57324 KB |
Output is correct |
69 |
Correct |
503 ms |
61716 KB |
Output is correct |
70 |
Correct |
462 ms |
55800 KB |
Output is correct |