# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
700209 |
2023-02-18T20:45:29 Z |
mnbvcxz123 |
Race (IOI11_race) |
C++17 |
|
928 ms |
41960 KB |
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ar=array<ll,2>;
ll n,k,res=1e7;
vector<ar>g[200000];
ll sz[200000];
bool used[200000];
map<ll,ll>mp;
void siz(ll v, ll e){
sz[v]=1;
for(const auto&[i,w]:g[v])
if(i!=e and !used[i]) siz(i,v),sz[v]+=sz[i];
}
ll get(ll v, ll e, ll des){
for(const auto&[i,w]:g[v])
if(i!=e and !used[i] and sz[i]>des) return get(i,v,des);
return v;
}
void help(ll v, ll e, ll km, ll d, bool fill){
if(km>k) return;
if(fill){
if(!mp.count(km)) mp[km]=d;
else mp[km]=min(mp[km],d);
}
else{
if(km==k) res=min(res,d);
else if(mp.count(k-km)) res=min(res,d+mp[k-km]);
}
for(const auto&[i,w]:g[v])
if(i!=e and !used[i]) help(i,v,km+w,d+1,fill);
}
void decomp(ll v=0){
siz(v,-1);
ll c=get(v,-1,sz[v]>>1);
used[c]=1;
for(const auto&[i,w]:g[c])
if(!used[i]){
help(i,c,w,1,0);
help(i,c,w,1,1);
}
mp.clear();
for(const auto&[i,w]:g[c])
if(!used[i]) decomp(i);
}
int best_path(int N, int K, int H[][2],int L[]){
n=N;
k=K;
for(ll i=0;i<n-1;++i){
g[H[i][0]].push_back({H[i][1],L[i]});
g[H[i][1]].push_back({H[i][0],L[i]});
}
decomp();
if(res==1e7) res=-1;
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4948 KB |
Output is correct |
2 |
Correct |
4 ms |
4948 KB |
Output is correct |
3 |
Correct |
2 ms |
4948 KB |
Output is correct |
4 |
Correct |
2 ms |
4948 KB |
Output is correct |
5 |
Correct |
3 ms |
4948 KB |
Output is correct |
6 |
Correct |
2 ms |
4948 KB |
Output is correct |
7 |
Correct |
2 ms |
4936 KB |
Output is correct |
8 |
Correct |
3 ms |
4948 KB |
Output is correct |
9 |
Correct |
3 ms |
4948 KB |
Output is correct |
10 |
Correct |
2 ms |
4948 KB |
Output is correct |
11 |
Correct |
3 ms |
4948 KB |
Output is correct |
12 |
Correct |
4 ms |
4948 KB |
Output is correct |
13 |
Correct |
3 ms |
4948 KB |
Output is correct |
14 |
Correct |
3 ms |
4948 KB |
Output is correct |
15 |
Correct |
3 ms |
5032 KB |
Output is correct |
16 |
Correct |
2 ms |
4948 KB |
Output is correct |
17 |
Correct |
3 ms |
4948 KB |
Output is correct |
18 |
Correct |
3 ms |
4948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4948 KB |
Output is correct |
2 |
Correct |
4 ms |
4948 KB |
Output is correct |
3 |
Correct |
2 ms |
4948 KB |
Output is correct |
4 |
Correct |
2 ms |
4948 KB |
Output is correct |
5 |
Correct |
3 ms |
4948 KB |
Output is correct |
6 |
Correct |
2 ms |
4948 KB |
Output is correct |
7 |
Correct |
2 ms |
4936 KB |
Output is correct |
8 |
Correct |
3 ms |
4948 KB |
Output is correct |
9 |
Correct |
3 ms |
4948 KB |
Output is correct |
10 |
Correct |
2 ms |
4948 KB |
Output is correct |
11 |
Correct |
3 ms |
4948 KB |
Output is correct |
12 |
Correct |
4 ms |
4948 KB |
Output is correct |
13 |
Correct |
3 ms |
4948 KB |
Output is correct |
14 |
Correct |
3 ms |
4948 KB |
Output is correct |
15 |
Correct |
3 ms |
5032 KB |
Output is correct |
16 |
Correct |
2 ms |
4948 KB |
Output is correct |
17 |
Correct |
3 ms |
4948 KB |
Output is correct |
18 |
Correct |
3 ms |
4948 KB |
Output is correct |
19 |
Correct |
2 ms |
4948 KB |
Output is correct |
20 |
Correct |
3 ms |
4948 KB |
Output is correct |
21 |
Correct |
4 ms |
5076 KB |
Output is correct |
22 |
Correct |
3 ms |
5092 KB |
Output is correct |
23 |
Correct |
3 ms |
5076 KB |
Output is correct |
24 |
Correct |
3 ms |
5076 KB |
Output is correct |
25 |
Correct |
4 ms |
5076 KB |
Output is correct |
26 |
Correct |
3 ms |
5076 KB |
Output is correct |
27 |
Correct |
3 ms |
5076 KB |
Output is correct |
28 |
Correct |
4 ms |
5076 KB |
Output is correct |
29 |
Correct |
4 ms |
5148 KB |
Output is correct |
30 |
Correct |
4 ms |
5076 KB |
Output is correct |
31 |
Correct |
4 ms |
5076 KB |
Output is correct |
32 |
Correct |
4 ms |
5076 KB |
Output is correct |
33 |
Correct |
4 ms |
5152 KB |
Output is correct |
34 |
Correct |
3 ms |
5076 KB |
Output is correct |
35 |
Correct |
3 ms |
5076 KB |
Output is correct |
36 |
Correct |
3 ms |
5076 KB |
Output is correct |
37 |
Correct |
3 ms |
5076 KB |
Output is correct |
38 |
Correct |
4 ms |
5076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4948 KB |
Output is correct |
2 |
Correct |
4 ms |
4948 KB |
Output is correct |
3 |
Correct |
2 ms |
4948 KB |
Output is correct |
4 |
Correct |
2 ms |
4948 KB |
Output is correct |
5 |
Correct |
3 ms |
4948 KB |
Output is correct |
6 |
Correct |
2 ms |
4948 KB |
Output is correct |
7 |
Correct |
2 ms |
4936 KB |
Output is correct |
8 |
Correct |
3 ms |
4948 KB |
Output is correct |
9 |
Correct |
3 ms |
4948 KB |
Output is correct |
10 |
Correct |
2 ms |
4948 KB |
Output is correct |
11 |
Correct |
3 ms |
4948 KB |
Output is correct |
12 |
Correct |
4 ms |
4948 KB |
Output is correct |
13 |
Correct |
3 ms |
4948 KB |
Output is correct |
14 |
Correct |
3 ms |
4948 KB |
Output is correct |
15 |
Correct |
3 ms |
5032 KB |
Output is correct |
16 |
Correct |
2 ms |
4948 KB |
Output is correct |
17 |
Correct |
3 ms |
4948 KB |
Output is correct |
18 |
Correct |
3 ms |
4948 KB |
Output is correct |
19 |
Correct |
185 ms |
12156 KB |
Output is correct |
20 |
Correct |
182 ms |
12160 KB |
Output is correct |
21 |
Correct |
192 ms |
12080 KB |
Output is correct |
22 |
Correct |
184 ms |
12184 KB |
Output is correct |
23 |
Correct |
78 ms |
12560 KB |
Output is correct |
24 |
Correct |
66 ms |
11704 KB |
Output is correct |
25 |
Correct |
126 ms |
15052 KB |
Output is correct |
26 |
Correct |
92 ms |
17888 KB |
Output is correct |
27 |
Correct |
176 ms |
19708 KB |
Output is correct |
28 |
Correct |
242 ms |
31136 KB |
Output is correct |
29 |
Correct |
240 ms |
30024 KB |
Output is correct |
30 |
Correct |
176 ms |
19756 KB |
Output is correct |
31 |
Correct |
186 ms |
19832 KB |
Output is correct |
32 |
Correct |
199 ms |
19788 KB |
Output is correct |
33 |
Correct |
248 ms |
18528 KB |
Output is correct |
34 |
Correct |
167 ms |
18764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4948 KB |
Output is correct |
2 |
Correct |
4 ms |
4948 KB |
Output is correct |
3 |
Correct |
2 ms |
4948 KB |
Output is correct |
4 |
Correct |
2 ms |
4948 KB |
Output is correct |
5 |
Correct |
3 ms |
4948 KB |
Output is correct |
6 |
Correct |
2 ms |
4948 KB |
Output is correct |
7 |
Correct |
2 ms |
4936 KB |
Output is correct |
8 |
Correct |
3 ms |
4948 KB |
Output is correct |
9 |
Correct |
3 ms |
4948 KB |
Output is correct |
10 |
Correct |
2 ms |
4948 KB |
Output is correct |
11 |
Correct |
3 ms |
4948 KB |
Output is correct |
12 |
Correct |
4 ms |
4948 KB |
Output is correct |
13 |
Correct |
3 ms |
4948 KB |
Output is correct |
14 |
Correct |
3 ms |
4948 KB |
Output is correct |
15 |
Correct |
3 ms |
5032 KB |
Output is correct |
16 |
Correct |
2 ms |
4948 KB |
Output is correct |
17 |
Correct |
3 ms |
4948 KB |
Output is correct |
18 |
Correct |
3 ms |
4948 KB |
Output is correct |
19 |
Correct |
2 ms |
4948 KB |
Output is correct |
20 |
Correct |
3 ms |
4948 KB |
Output is correct |
21 |
Correct |
4 ms |
5076 KB |
Output is correct |
22 |
Correct |
3 ms |
5092 KB |
Output is correct |
23 |
Correct |
3 ms |
5076 KB |
Output is correct |
24 |
Correct |
3 ms |
5076 KB |
Output is correct |
25 |
Correct |
4 ms |
5076 KB |
Output is correct |
26 |
Correct |
3 ms |
5076 KB |
Output is correct |
27 |
Correct |
3 ms |
5076 KB |
Output is correct |
28 |
Correct |
4 ms |
5076 KB |
Output is correct |
29 |
Correct |
4 ms |
5148 KB |
Output is correct |
30 |
Correct |
4 ms |
5076 KB |
Output is correct |
31 |
Correct |
4 ms |
5076 KB |
Output is correct |
32 |
Correct |
4 ms |
5076 KB |
Output is correct |
33 |
Correct |
4 ms |
5152 KB |
Output is correct |
34 |
Correct |
3 ms |
5076 KB |
Output is correct |
35 |
Correct |
3 ms |
5076 KB |
Output is correct |
36 |
Correct |
3 ms |
5076 KB |
Output is correct |
37 |
Correct |
3 ms |
5076 KB |
Output is correct |
38 |
Correct |
4 ms |
5076 KB |
Output is correct |
39 |
Correct |
185 ms |
12156 KB |
Output is correct |
40 |
Correct |
182 ms |
12160 KB |
Output is correct |
41 |
Correct |
192 ms |
12080 KB |
Output is correct |
42 |
Correct |
184 ms |
12184 KB |
Output is correct |
43 |
Correct |
78 ms |
12560 KB |
Output is correct |
44 |
Correct |
66 ms |
11704 KB |
Output is correct |
45 |
Correct |
126 ms |
15052 KB |
Output is correct |
46 |
Correct |
92 ms |
17888 KB |
Output is correct |
47 |
Correct |
176 ms |
19708 KB |
Output is correct |
48 |
Correct |
242 ms |
31136 KB |
Output is correct |
49 |
Correct |
240 ms |
30024 KB |
Output is correct |
50 |
Correct |
176 ms |
19756 KB |
Output is correct |
51 |
Correct |
186 ms |
19832 KB |
Output is correct |
52 |
Correct |
199 ms |
19788 KB |
Output is correct |
53 |
Correct |
248 ms |
18528 KB |
Output is correct |
54 |
Correct |
167 ms |
18764 KB |
Output is correct |
55 |
Correct |
19 ms |
5904 KB |
Output is correct |
56 |
Correct |
14 ms |
5740 KB |
Output is correct |
57 |
Correct |
129 ms |
12456 KB |
Output is correct |
58 |
Correct |
40 ms |
11692 KB |
Output is correct |
59 |
Correct |
266 ms |
22744 KB |
Output is correct |
60 |
Correct |
799 ms |
41960 KB |
Output is correct |
61 |
Correct |
238 ms |
20236 KB |
Output is correct |
62 |
Correct |
258 ms |
20060 KB |
Output is correct |
63 |
Correct |
320 ms |
20024 KB |
Output is correct |
64 |
Correct |
928 ms |
25464 KB |
Output is correct |
65 |
Correct |
203 ms |
19388 KB |
Output is correct |
66 |
Correct |
498 ms |
28196 KB |
Output is correct |
67 |
Correct |
117 ms |
18536 KB |
Output is correct |
68 |
Correct |
356 ms |
24148 KB |
Output is correct |
69 |
Correct |
347 ms |
23676 KB |
Output is correct |
70 |
Correct |
334 ms |
23252 KB |
Output is correct |