# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
499804 |
2021-12-29T13:18:14 Z |
HappyPacMan |
Race (IOI11_race) |
C++14 |
|
458 ms |
97988 KB |
#include "race.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 15;
vector<pair<int,int> > adj[MAXN];
map<long long,int> cost[MAXN];
int res = MAXN;
void dfs(int u,int p,long long k,long long d,int l){
cost[u][d] = l;
for(auto v : adj[u]){
if(v.first == p) continue;
dfs(v.first,u,k,d+v.second,l+1);
if(cost[u].size() < cost[v.first].size()) swap(cost[u],cost[v.first]);
for(auto w : cost[v.first]){
long long split = k - w.first + 2*d;
if(cost[u].count(split)) res = min(res,w.second+cost[u][split]-2*l);
}
for(auto w : cost[v.first]){
if(cost[u].count(w.first)) cost[u][w.first] = min(cost[u][w.first],w.second);
else cost[u][w.first] = w.second;
}
}
if(cost[u].count(d+k)) res = min(res,cost[u][d+k]-l);
}
int best_path(int N, int K, int H[][2], int L[]){
for(int i=0;i<N-1;i++){
adj[H[i][0]].emplace_back(H[i][1],L[i]);
adj[H[i][1]].emplace_back(H[i][0],L[i]);
}
dfs(0,0,K,0,0);
if(res == MAXN) res = -1;
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
14412 KB |
Output is correct |
2 |
Correct |
7 ms |
14412 KB |
Output is correct |
3 |
Correct |
7 ms |
14412 KB |
Output is correct |
4 |
Correct |
7 ms |
14412 KB |
Output is correct |
5 |
Correct |
7 ms |
14360 KB |
Output is correct |
6 |
Correct |
6 ms |
14412 KB |
Output is correct |
7 |
Correct |
7 ms |
14392 KB |
Output is correct |
8 |
Correct |
7 ms |
14412 KB |
Output is correct |
9 |
Correct |
7 ms |
14412 KB |
Output is correct |
10 |
Correct |
7 ms |
14412 KB |
Output is correct |
11 |
Correct |
7 ms |
14412 KB |
Output is correct |
12 |
Correct |
7 ms |
14412 KB |
Output is correct |
13 |
Correct |
7 ms |
14412 KB |
Output is correct |
14 |
Correct |
7 ms |
14392 KB |
Output is correct |
15 |
Correct |
7 ms |
14412 KB |
Output is correct |
16 |
Correct |
8 ms |
14412 KB |
Output is correct |
17 |
Correct |
7 ms |
14364 KB |
Output is correct |
18 |
Correct |
7 ms |
14412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
14412 KB |
Output is correct |
2 |
Correct |
7 ms |
14412 KB |
Output is correct |
3 |
Correct |
7 ms |
14412 KB |
Output is correct |
4 |
Correct |
7 ms |
14412 KB |
Output is correct |
5 |
Correct |
7 ms |
14360 KB |
Output is correct |
6 |
Correct |
6 ms |
14412 KB |
Output is correct |
7 |
Correct |
7 ms |
14392 KB |
Output is correct |
8 |
Correct |
7 ms |
14412 KB |
Output is correct |
9 |
Correct |
7 ms |
14412 KB |
Output is correct |
10 |
Correct |
7 ms |
14412 KB |
Output is correct |
11 |
Correct |
7 ms |
14412 KB |
Output is correct |
12 |
Correct |
7 ms |
14412 KB |
Output is correct |
13 |
Correct |
7 ms |
14412 KB |
Output is correct |
14 |
Correct |
7 ms |
14392 KB |
Output is correct |
15 |
Correct |
7 ms |
14412 KB |
Output is correct |
16 |
Correct |
8 ms |
14412 KB |
Output is correct |
17 |
Correct |
7 ms |
14364 KB |
Output is correct |
18 |
Correct |
7 ms |
14412 KB |
Output is correct |
19 |
Correct |
7 ms |
14284 KB |
Output is correct |
20 |
Correct |
7 ms |
14412 KB |
Output is correct |
21 |
Correct |
8 ms |
14540 KB |
Output is correct |
22 |
Correct |
7 ms |
14668 KB |
Output is correct |
23 |
Correct |
8 ms |
14668 KB |
Output is correct |
24 |
Correct |
8 ms |
14668 KB |
Output is correct |
25 |
Correct |
8 ms |
14684 KB |
Output is correct |
26 |
Correct |
9 ms |
14696 KB |
Output is correct |
27 |
Correct |
7 ms |
14540 KB |
Output is correct |
28 |
Correct |
9 ms |
14676 KB |
Output is correct |
29 |
Correct |
9 ms |
14664 KB |
Output is correct |
30 |
Correct |
8 ms |
14668 KB |
Output is correct |
31 |
Correct |
8 ms |
14688 KB |
Output is correct |
32 |
Correct |
8 ms |
14668 KB |
Output is correct |
33 |
Correct |
8 ms |
14668 KB |
Output is correct |
34 |
Correct |
8 ms |
14540 KB |
Output is correct |
35 |
Correct |
8 ms |
14532 KB |
Output is correct |
36 |
Correct |
8 ms |
14540 KB |
Output is correct |
37 |
Correct |
10 ms |
14600 KB |
Output is correct |
38 |
Correct |
8 ms |
14540 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
14412 KB |
Output is correct |
2 |
Correct |
7 ms |
14412 KB |
Output is correct |
3 |
Correct |
7 ms |
14412 KB |
Output is correct |
4 |
Correct |
7 ms |
14412 KB |
Output is correct |
5 |
Correct |
7 ms |
14360 KB |
Output is correct |
6 |
Correct |
6 ms |
14412 KB |
Output is correct |
7 |
Correct |
7 ms |
14392 KB |
Output is correct |
8 |
Correct |
7 ms |
14412 KB |
Output is correct |
9 |
Correct |
7 ms |
14412 KB |
Output is correct |
10 |
Correct |
7 ms |
14412 KB |
Output is correct |
11 |
Correct |
7 ms |
14412 KB |
Output is correct |
12 |
Correct |
7 ms |
14412 KB |
Output is correct |
13 |
Correct |
7 ms |
14412 KB |
Output is correct |
14 |
Correct |
7 ms |
14392 KB |
Output is correct |
15 |
Correct |
7 ms |
14412 KB |
Output is correct |
16 |
Correct |
8 ms |
14412 KB |
Output is correct |
17 |
Correct |
7 ms |
14364 KB |
Output is correct |
18 |
Correct |
7 ms |
14412 KB |
Output is correct |
19 |
Correct |
112 ms |
34812 KB |
Output is correct |
20 |
Correct |
116 ms |
34736 KB |
Output is correct |
21 |
Correct |
127 ms |
34736 KB |
Output is correct |
22 |
Correct |
119 ms |
34164 KB |
Output is correct |
23 |
Correct |
155 ms |
46728 KB |
Output is correct |
24 |
Correct |
124 ms |
37476 KB |
Output is correct |
25 |
Correct |
103 ms |
34640 KB |
Output is correct |
26 |
Correct |
57 ms |
42180 KB |
Output is correct |
27 |
Correct |
184 ms |
43388 KB |
Output is correct |
28 |
Correct |
278 ms |
82376 KB |
Output is correct |
29 |
Correct |
300 ms |
80652 KB |
Output is correct |
30 |
Correct |
184 ms |
43396 KB |
Output is correct |
31 |
Correct |
191 ms |
43356 KB |
Output is correct |
32 |
Correct |
249 ms |
43408 KB |
Output is correct |
33 |
Correct |
221 ms |
48320 KB |
Output is correct |
34 |
Correct |
313 ms |
80280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
14412 KB |
Output is correct |
2 |
Correct |
7 ms |
14412 KB |
Output is correct |
3 |
Correct |
7 ms |
14412 KB |
Output is correct |
4 |
Correct |
7 ms |
14412 KB |
Output is correct |
5 |
Correct |
7 ms |
14360 KB |
Output is correct |
6 |
Correct |
6 ms |
14412 KB |
Output is correct |
7 |
Correct |
7 ms |
14392 KB |
Output is correct |
8 |
Correct |
7 ms |
14412 KB |
Output is correct |
9 |
Correct |
7 ms |
14412 KB |
Output is correct |
10 |
Correct |
7 ms |
14412 KB |
Output is correct |
11 |
Correct |
7 ms |
14412 KB |
Output is correct |
12 |
Correct |
7 ms |
14412 KB |
Output is correct |
13 |
Correct |
7 ms |
14412 KB |
Output is correct |
14 |
Correct |
7 ms |
14392 KB |
Output is correct |
15 |
Correct |
7 ms |
14412 KB |
Output is correct |
16 |
Correct |
8 ms |
14412 KB |
Output is correct |
17 |
Correct |
7 ms |
14364 KB |
Output is correct |
18 |
Correct |
7 ms |
14412 KB |
Output is correct |
19 |
Correct |
7 ms |
14284 KB |
Output is correct |
20 |
Correct |
7 ms |
14412 KB |
Output is correct |
21 |
Correct |
8 ms |
14540 KB |
Output is correct |
22 |
Correct |
7 ms |
14668 KB |
Output is correct |
23 |
Correct |
8 ms |
14668 KB |
Output is correct |
24 |
Correct |
8 ms |
14668 KB |
Output is correct |
25 |
Correct |
8 ms |
14684 KB |
Output is correct |
26 |
Correct |
9 ms |
14696 KB |
Output is correct |
27 |
Correct |
7 ms |
14540 KB |
Output is correct |
28 |
Correct |
9 ms |
14676 KB |
Output is correct |
29 |
Correct |
9 ms |
14664 KB |
Output is correct |
30 |
Correct |
8 ms |
14668 KB |
Output is correct |
31 |
Correct |
8 ms |
14688 KB |
Output is correct |
32 |
Correct |
8 ms |
14668 KB |
Output is correct |
33 |
Correct |
8 ms |
14668 KB |
Output is correct |
34 |
Correct |
8 ms |
14540 KB |
Output is correct |
35 |
Correct |
8 ms |
14532 KB |
Output is correct |
36 |
Correct |
8 ms |
14540 KB |
Output is correct |
37 |
Correct |
10 ms |
14600 KB |
Output is correct |
38 |
Correct |
8 ms |
14540 KB |
Output is correct |
39 |
Correct |
112 ms |
34812 KB |
Output is correct |
40 |
Correct |
116 ms |
34736 KB |
Output is correct |
41 |
Correct |
127 ms |
34736 KB |
Output is correct |
42 |
Correct |
119 ms |
34164 KB |
Output is correct |
43 |
Correct |
155 ms |
46728 KB |
Output is correct |
44 |
Correct |
124 ms |
37476 KB |
Output is correct |
45 |
Correct |
103 ms |
34640 KB |
Output is correct |
46 |
Correct |
57 ms |
42180 KB |
Output is correct |
47 |
Correct |
184 ms |
43388 KB |
Output is correct |
48 |
Correct |
278 ms |
82376 KB |
Output is correct |
49 |
Correct |
300 ms |
80652 KB |
Output is correct |
50 |
Correct |
184 ms |
43396 KB |
Output is correct |
51 |
Correct |
191 ms |
43356 KB |
Output is correct |
52 |
Correct |
249 ms |
43408 KB |
Output is correct |
53 |
Correct |
221 ms |
48320 KB |
Output is correct |
54 |
Correct |
313 ms |
80280 KB |
Output is correct |
55 |
Correct |
20 ms |
17308 KB |
Output is correct |
56 |
Correct |
14 ms |
16000 KB |
Output is correct |
57 |
Correct |
74 ms |
32104 KB |
Output is correct |
58 |
Correct |
50 ms |
25732 KB |
Output is correct |
59 |
Correct |
91 ms |
48308 KB |
Output is correct |
60 |
Correct |
263 ms |
81220 KB |
Output is correct |
61 |
Correct |
230 ms |
46992 KB |
Output is correct |
62 |
Correct |
193 ms |
43332 KB |
Output is correct |
63 |
Correct |
242 ms |
43448 KB |
Output is correct |
64 |
Correct |
458 ms |
97988 KB |
Output is correct |
65 |
Correct |
420 ms |
95788 KB |
Output is correct |
66 |
Correct |
295 ms |
77332 KB |
Output is correct |
67 |
Correct |
181 ms |
37296 KB |
Output is correct |
68 |
Correct |
404 ms |
59772 KB |
Output is correct |
69 |
Correct |
385 ms |
64708 KB |
Output is correct |
70 |
Correct |
326 ms |
57860 KB |
Output is correct |