# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
875652 |
2023-11-20T10:19:27 Z |
Huseyn123 |
Race (IOI11_race) |
C++17 |
|
339 ms |
94268 KB |
#include "race.h"
#include <bits/stdc++.h>
#define MAX 200001
#define INF INT_MAX
using namespace std;
multiset<pair<int,int>> a[MAX];
int k;
vector<int> dist;
vector<int> dep;
vector<vector<pair<int,int>>> g;
int res=INF;
void dfs(int v,int prev){
a[v].insert(make_pair(dist[v],dep[v]));
for(auto x:g[v]){
if(x.first==prev){
continue;
}
dist[x.first]=dist[v]+x.second;
dep[x.first]=dep[v]+1;
dfs(x.first,v);
if(a[v].size()<a[x.first].size()){
swap(a[v],a[x.first]);
}
for(auto y:a[x.first]){
auto it=a[v].lower_bound(make_pair(k+2*dist[v]-y.first,0));
if(it!=a[v].end() && (*it).first==k+2*dist[v]-y.first){
res=min(res,(*it).second+y.second-2*dep[v]);
}
}
for(auto y:a[x.first]){
a[v].insert(y);
}
}
}
int best_path(int N, int K, int H[][2], int L[])
{
k=K;
g.resize(N+1);
dist.resize(N+1,0);
dep.resize(N+1,0);
for(int i=0;i<N-1;i++){
g[H[i][0]].push_back(make_pair(H[i][1],L[i]));
g[H[i][1]].push_back(make_pair(H[i][0],L[i]));
}
dfs(0,-1);
if(res==INF){
res=-1;
}
return res;
}
/*
int main(){
int n,k;
cin >> n >> k;
int h[n-1][2];
int l[n];
for(int i=0;i<n-1;i++){
cin >> h[i][0] >> h[i][1];
}
for(int i=0;i<n-1;i++){
cin >> l[i];
}
cout << "h" << " " << best_path(n,k,h,l) << "\n";
}
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
13404 KB |
Output is correct |
2 |
Correct |
3 ms |
13404 KB |
Output is correct |
3 |
Correct |
2 ms |
13404 KB |
Output is correct |
4 |
Correct |
3 ms |
13508 KB |
Output is correct |
5 |
Correct |
3 ms |
13404 KB |
Output is correct |
6 |
Correct |
2 ms |
13404 KB |
Output is correct |
7 |
Correct |
3 ms |
13404 KB |
Output is correct |
8 |
Correct |
3 ms |
13404 KB |
Output is correct |
9 |
Correct |
3 ms |
13404 KB |
Output is correct |
10 |
Correct |
3 ms |
13404 KB |
Output is correct |
11 |
Correct |
2 ms |
13404 KB |
Output is correct |
12 |
Correct |
2 ms |
13404 KB |
Output is correct |
13 |
Correct |
2 ms |
13404 KB |
Output is correct |
14 |
Correct |
2 ms |
13508 KB |
Output is correct |
15 |
Correct |
3 ms |
13656 KB |
Output is correct |
16 |
Correct |
3 ms |
13404 KB |
Output is correct |
17 |
Correct |
2 ms |
13404 KB |
Output is correct |
18 |
Correct |
2 ms |
13404 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
13404 KB |
Output is correct |
2 |
Correct |
3 ms |
13404 KB |
Output is correct |
3 |
Correct |
2 ms |
13404 KB |
Output is correct |
4 |
Correct |
3 ms |
13508 KB |
Output is correct |
5 |
Correct |
3 ms |
13404 KB |
Output is correct |
6 |
Correct |
2 ms |
13404 KB |
Output is correct |
7 |
Correct |
3 ms |
13404 KB |
Output is correct |
8 |
Correct |
3 ms |
13404 KB |
Output is correct |
9 |
Correct |
3 ms |
13404 KB |
Output is correct |
10 |
Correct |
3 ms |
13404 KB |
Output is correct |
11 |
Correct |
2 ms |
13404 KB |
Output is correct |
12 |
Correct |
2 ms |
13404 KB |
Output is correct |
13 |
Correct |
2 ms |
13404 KB |
Output is correct |
14 |
Correct |
2 ms |
13508 KB |
Output is correct |
15 |
Correct |
3 ms |
13656 KB |
Output is correct |
16 |
Correct |
3 ms |
13404 KB |
Output is correct |
17 |
Correct |
2 ms |
13404 KB |
Output is correct |
18 |
Correct |
2 ms |
13404 KB |
Output is correct |
19 |
Correct |
3 ms |
13404 KB |
Output is correct |
20 |
Correct |
3 ms |
13404 KB |
Output is correct |
21 |
Correct |
3 ms |
13660 KB |
Output is correct |
22 |
Correct |
3 ms |
13744 KB |
Output is correct |
23 |
Correct |
3 ms |
13752 KB |
Output is correct |
24 |
Correct |
3 ms |
13660 KB |
Output is correct |
25 |
Correct |
3 ms |
13660 KB |
Output is correct |
26 |
Correct |
3 ms |
13744 KB |
Output is correct |
27 |
Correct |
4 ms |
13660 KB |
Output is correct |
28 |
Correct |
3 ms |
13920 KB |
Output is correct |
29 |
Correct |
3 ms |
13660 KB |
Output is correct |
30 |
Correct |
3 ms |
13660 KB |
Output is correct |
31 |
Correct |
3 ms |
13660 KB |
Output is correct |
32 |
Correct |
3 ms |
13660 KB |
Output is correct |
33 |
Correct |
3 ms |
13660 KB |
Output is correct |
34 |
Correct |
3 ms |
13656 KB |
Output is correct |
35 |
Correct |
3 ms |
13668 KB |
Output is correct |
36 |
Correct |
3 ms |
13668 KB |
Output is correct |
37 |
Correct |
3 ms |
13672 KB |
Output is correct |
38 |
Correct |
4 ms |
13492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
13404 KB |
Output is correct |
2 |
Correct |
3 ms |
13404 KB |
Output is correct |
3 |
Correct |
2 ms |
13404 KB |
Output is correct |
4 |
Correct |
3 ms |
13508 KB |
Output is correct |
5 |
Correct |
3 ms |
13404 KB |
Output is correct |
6 |
Correct |
2 ms |
13404 KB |
Output is correct |
7 |
Correct |
3 ms |
13404 KB |
Output is correct |
8 |
Correct |
3 ms |
13404 KB |
Output is correct |
9 |
Correct |
3 ms |
13404 KB |
Output is correct |
10 |
Correct |
3 ms |
13404 KB |
Output is correct |
11 |
Correct |
2 ms |
13404 KB |
Output is correct |
12 |
Correct |
2 ms |
13404 KB |
Output is correct |
13 |
Correct |
2 ms |
13404 KB |
Output is correct |
14 |
Correct |
2 ms |
13508 KB |
Output is correct |
15 |
Correct |
3 ms |
13656 KB |
Output is correct |
16 |
Correct |
3 ms |
13404 KB |
Output is correct |
17 |
Correct |
2 ms |
13404 KB |
Output is correct |
18 |
Correct |
2 ms |
13404 KB |
Output is correct |
19 |
Correct |
158 ms |
54368 KB |
Output is correct |
20 |
Correct |
180 ms |
53760 KB |
Output is correct |
21 |
Correct |
158 ms |
54160 KB |
Output is correct |
22 |
Correct |
165 ms |
50256 KB |
Output is correct |
23 |
Correct |
171 ms |
62996 KB |
Output is correct |
24 |
Correct |
140 ms |
51536 KB |
Output is correct |
25 |
Correct |
91 ms |
41496 KB |
Output is correct |
26 |
Correct |
60 ms |
45136 KB |
Output is correct |
27 |
Correct |
220 ms |
60392 KB |
Output is correct |
28 |
Correct |
194 ms |
75044 KB |
Output is correct |
29 |
Correct |
188 ms |
73908 KB |
Output is correct |
30 |
Correct |
183 ms |
60328 KB |
Output is correct |
31 |
Correct |
188 ms |
60312 KB |
Output is correct |
32 |
Correct |
241 ms |
60244 KB |
Output is correct |
33 |
Correct |
231 ms |
75452 KB |
Output is correct |
34 |
Correct |
239 ms |
74796 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
13404 KB |
Output is correct |
2 |
Correct |
3 ms |
13404 KB |
Output is correct |
3 |
Correct |
2 ms |
13404 KB |
Output is correct |
4 |
Correct |
3 ms |
13508 KB |
Output is correct |
5 |
Correct |
3 ms |
13404 KB |
Output is correct |
6 |
Correct |
2 ms |
13404 KB |
Output is correct |
7 |
Correct |
3 ms |
13404 KB |
Output is correct |
8 |
Correct |
3 ms |
13404 KB |
Output is correct |
9 |
Correct |
3 ms |
13404 KB |
Output is correct |
10 |
Correct |
3 ms |
13404 KB |
Output is correct |
11 |
Correct |
2 ms |
13404 KB |
Output is correct |
12 |
Correct |
2 ms |
13404 KB |
Output is correct |
13 |
Correct |
2 ms |
13404 KB |
Output is correct |
14 |
Correct |
2 ms |
13508 KB |
Output is correct |
15 |
Correct |
3 ms |
13656 KB |
Output is correct |
16 |
Correct |
3 ms |
13404 KB |
Output is correct |
17 |
Correct |
2 ms |
13404 KB |
Output is correct |
18 |
Correct |
2 ms |
13404 KB |
Output is correct |
19 |
Correct |
3 ms |
13404 KB |
Output is correct |
20 |
Correct |
3 ms |
13404 KB |
Output is correct |
21 |
Correct |
3 ms |
13660 KB |
Output is correct |
22 |
Correct |
3 ms |
13744 KB |
Output is correct |
23 |
Correct |
3 ms |
13752 KB |
Output is correct |
24 |
Correct |
3 ms |
13660 KB |
Output is correct |
25 |
Correct |
3 ms |
13660 KB |
Output is correct |
26 |
Correct |
3 ms |
13744 KB |
Output is correct |
27 |
Correct |
4 ms |
13660 KB |
Output is correct |
28 |
Correct |
3 ms |
13920 KB |
Output is correct |
29 |
Correct |
3 ms |
13660 KB |
Output is correct |
30 |
Correct |
3 ms |
13660 KB |
Output is correct |
31 |
Correct |
3 ms |
13660 KB |
Output is correct |
32 |
Correct |
3 ms |
13660 KB |
Output is correct |
33 |
Correct |
3 ms |
13660 KB |
Output is correct |
34 |
Correct |
3 ms |
13656 KB |
Output is correct |
35 |
Correct |
3 ms |
13668 KB |
Output is correct |
36 |
Correct |
3 ms |
13668 KB |
Output is correct |
37 |
Correct |
3 ms |
13672 KB |
Output is correct |
38 |
Correct |
4 ms |
13492 KB |
Output is correct |
39 |
Correct |
158 ms |
54368 KB |
Output is correct |
40 |
Correct |
180 ms |
53760 KB |
Output is correct |
41 |
Correct |
158 ms |
54160 KB |
Output is correct |
42 |
Correct |
165 ms |
50256 KB |
Output is correct |
43 |
Correct |
171 ms |
62996 KB |
Output is correct |
44 |
Correct |
140 ms |
51536 KB |
Output is correct |
45 |
Correct |
91 ms |
41496 KB |
Output is correct |
46 |
Correct |
60 ms |
45136 KB |
Output is correct |
47 |
Correct |
220 ms |
60392 KB |
Output is correct |
48 |
Correct |
194 ms |
75044 KB |
Output is correct |
49 |
Correct |
188 ms |
73908 KB |
Output is correct |
50 |
Correct |
183 ms |
60328 KB |
Output is correct |
51 |
Correct |
188 ms |
60312 KB |
Output is correct |
52 |
Correct |
241 ms |
60244 KB |
Output is correct |
53 |
Correct |
231 ms |
75452 KB |
Output is correct |
54 |
Correct |
239 ms |
74796 KB |
Output is correct |
55 |
Correct |
13 ms |
16344 KB |
Output is correct |
56 |
Correct |
13 ms |
16732 KB |
Output is correct |
57 |
Correct |
155 ms |
64592 KB |
Output is correct |
58 |
Correct |
76 ms |
33160 KB |
Output is correct |
59 |
Correct |
58 ms |
45136 KB |
Output is correct |
60 |
Correct |
186 ms |
74068 KB |
Output is correct |
61 |
Correct |
195 ms |
60500 KB |
Output is correct |
62 |
Correct |
184 ms |
60388 KB |
Output is correct |
63 |
Correct |
231 ms |
60240 KB |
Output is correct |
64 |
Correct |
334 ms |
94268 KB |
Output is correct |
65 |
Correct |
339 ms |
87084 KB |
Output is correct |
66 |
Correct |
208 ms |
71320 KB |
Output is correct |
67 |
Correct |
203 ms |
51936 KB |
Output is correct |
68 |
Correct |
239 ms |
60716 KB |
Output is correct |
69 |
Correct |
269 ms |
65356 KB |
Output is correct |
70 |
Correct |
222 ms |
58872 KB |
Output is correct |