# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
670574 |
2022-12-09T14:47:15 Z |
mseebacher |
Race (IOI11_race) |
C++17 |
|
3000 ms |
20876 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define MAXI (int)1e5
vector<int> ad[MAXI];
int shortest = 1e9;
int len = 0;
map<pair<int,int>,int> paths;
void dfs(int x,int e,ll summe,int cnt){
if(summe > len || cnt > shortest) return;
if(summe == len){
shortest = min(shortest,cnt);
return;
}
for(auto s: ad[x]){
if(s == e) continue;
dfs(s,x,summe+paths[{x,s}],cnt+1);
}
}
int best_path(int n, int k, int h[][2], int l[]){
len = k;
for(int i = 0;i<n-1;i++){
int u = h[i][0];
int v = h[i][1];
ad[u].push_back(v);
ad[v].push_back(u);
paths.insert({{u,v},l[i]});
paths.insert({{v,u},l[i]});
}
for(int i = 1;i<=n;i++){
dfs(i,i,0,1);
}
if(shortest == 1e9) return -1;
return shortest-1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
1 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2656 KB |
Output is correct |
5 |
Correct |
2 ms |
2644 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
1 ms |
2656 KB |
Output is correct |
8 |
Correct |
2 ms |
2644 KB |
Output is correct |
9 |
Correct |
2 ms |
2656 KB |
Output is correct |
10 |
Correct |
2 ms |
2644 KB |
Output is correct |
11 |
Correct |
2 ms |
2660 KB |
Output is correct |
12 |
Correct |
2 ms |
2644 KB |
Output is correct |
13 |
Correct |
2 ms |
2644 KB |
Output is correct |
14 |
Correct |
2 ms |
2644 KB |
Output is correct |
15 |
Correct |
2 ms |
2644 KB |
Output is correct |
16 |
Correct |
2 ms |
2644 KB |
Output is correct |
17 |
Correct |
2 ms |
2644 KB |
Output is correct |
18 |
Correct |
2 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
1 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2656 KB |
Output is correct |
5 |
Correct |
2 ms |
2644 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
1 ms |
2656 KB |
Output is correct |
8 |
Correct |
2 ms |
2644 KB |
Output is correct |
9 |
Correct |
2 ms |
2656 KB |
Output is correct |
10 |
Correct |
2 ms |
2644 KB |
Output is correct |
11 |
Correct |
2 ms |
2660 KB |
Output is correct |
12 |
Correct |
2 ms |
2644 KB |
Output is correct |
13 |
Correct |
2 ms |
2644 KB |
Output is correct |
14 |
Correct |
2 ms |
2644 KB |
Output is correct |
15 |
Correct |
2 ms |
2644 KB |
Output is correct |
16 |
Correct |
2 ms |
2644 KB |
Output is correct |
17 |
Correct |
2 ms |
2644 KB |
Output is correct |
18 |
Correct |
2 ms |
2652 KB |
Output is correct |
19 |
Correct |
1 ms |
2644 KB |
Output is correct |
20 |
Correct |
2 ms |
2644 KB |
Output is correct |
21 |
Correct |
71 ms |
2820 KB |
Output is correct |
22 |
Correct |
3 ms |
2772 KB |
Output is correct |
23 |
Correct |
3 ms |
2772 KB |
Output is correct |
24 |
Correct |
4 ms |
2804 KB |
Output is correct |
25 |
Correct |
72 ms |
2772 KB |
Output is correct |
26 |
Correct |
4 ms |
2772 KB |
Output is correct |
27 |
Correct |
2 ms |
2772 KB |
Output is correct |
28 |
Correct |
14 ms |
2848 KB |
Output is correct |
29 |
Correct |
35 ms |
2772 KB |
Output is correct |
30 |
Correct |
31 ms |
2772 KB |
Output is correct |
31 |
Correct |
66 ms |
2892 KB |
Output is correct |
32 |
Correct |
64 ms |
2796 KB |
Output is correct |
33 |
Correct |
54 ms |
2824 KB |
Output is correct |
34 |
Correct |
6 ms |
2772 KB |
Output is correct |
35 |
Correct |
7 ms |
2772 KB |
Output is correct |
36 |
Correct |
7 ms |
2772 KB |
Output is correct |
37 |
Correct |
42 ms |
2792 KB |
Output is correct |
38 |
Correct |
56 ms |
2788 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
1 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2656 KB |
Output is correct |
5 |
Correct |
2 ms |
2644 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
1 ms |
2656 KB |
Output is correct |
8 |
Correct |
2 ms |
2644 KB |
Output is correct |
9 |
Correct |
2 ms |
2656 KB |
Output is correct |
10 |
Correct |
2 ms |
2644 KB |
Output is correct |
11 |
Correct |
2 ms |
2660 KB |
Output is correct |
12 |
Correct |
2 ms |
2644 KB |
Output is correct |
13 |
Correct |
2 ms |
2644 KB |
Output is correct |
14 |
Correct |
2 ms |
2644 KB |
Output is correct |
15 |
Correct |
2 ms |
2644 KB |
Output is correct |
16 |
Correct |
2 ms |
2644 KB |
Output is correct |
17 |
Correct |
2 ms |
2644 KB |
Output is correct |
18 |
Correct |
2 ms |
2652 KB |
Output is correct |
19 |
Execution timed out |
3042 ms |
20876 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
1 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2656 KB |
Output is correct |
5 |
Correct |
2 ms |
2644 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
1 ms |
2656 KB |
Output is correct |
8 |
Correct |
2 ms |
2644 KB |
Output is correct |
9 |
Correct |
2 ms |
2656 KB |
Output is correct |
10 |
Correct |
2 ms |
2644 KB |
Output is correct |
11 |
Correct |
2 ms |
2660 KB |
Output is correct |
12 |
Correct |
2 ms |
2644 KB |
Output is correct |
13 |
Correct |
2 ms |
2644 KB |
Output is correct |
14 |
Correct |
2 ms |
2644 KB |
Output is correct |
15 |
Correct |
2 ms |
2644 KB |
Output is correct |
16 |
Correct |
2 ms |
2644 KB |
Output is correct |
17 |
Correct |
2 ms |
2644 KB |
Output is correct |
18 |
Correct |
2 ms |
2652 KB |
Output is correct |
19 |
Correct |
1 ms |
2644 KB |
Output is correct |
20 |
Correct |
2 ms |
2644 KB |
Output is correct |
21 |
Correct |
71 ms |
2820 KB |
Output is correct |
22 |
Correct |
3 ms |
2772 KB |
Output is correct |
23 |
Correct |
3 ms |
2772 KB |
Output is correct |
24 |
Correct |
4 ms |
2804 KB |
Output is correct |
25 |
Correct |
72 ms |
2772 KB |
Output is correct |
26 |
Correct |
4 ms |
2772 KB |
Output is correct |
27 |
Correct |
2 ms |
2772 KB |
Output is correct |
28 |
Correct |
14 ms |
2848 KB |
Output is correct |
29 |
Correct |
35 ms |
2772 KB |
Output is correct |
30 |
Correct |
31 ms |
2772 KB |
Output is correct |
31 |
Correct |
66 ms |
2892 KB |
Output is correct |
32 |
Correct |
64 ms |
2796 KB |
Output is correct |
33 |
Correct |
54 ms |
2824 KB |
Output is correct |
34 |
Correct |
6 ms |
2772 KB |
Output is correct |
35 |
Correct |
7 ms |
2772 KB |
Output is correct |
36 |
Correct |
7 ms |
2772 KB |
Output is correct |
37 |
Correct |
42 ms |
2792 KB |
Output is correct |
38 |
Correct |
56 ms |
2788 KB |
Output is correct |
39 |
Execution timed out |
3042 ms |
20876 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |