# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
824201 |
2023-08-13T17:54:25 Z |
Mouad_ouj |
Race (IOI11_race) |
C++17 |
|
240 ms |
114412 KB |
#include<bits/stdc++.h>
using namespace std;
int dp[200001][101],ans=200001,n,k;
vector<vector< pair<int,int>> > tree;
void dfs(int node,int par)
{
for(int x=0;x<tree[node].size();x++)
{
int to=tree[node][x].first;
int dis=tree[node][x].second;
if(par==to)
continue;
dfs(to,node);
for(int x=0;x<=k-dis;x++)
ans=min(ans,dp[node][x]+dp[to][k-dis-x]+1); //f sub sol
for(int x=0;x+dis<=k;x++)
dp[node][x+dis]=min(dp[node][x+dis],dp[to][x]+1); //s sub sol
}
}
int best_path(int N,int K,int bet[][2],int w[])
{
n=N;
k=K;
tree.resize(n+1);
for(int x=0;x<200001;x++)
{
for(int y=0;y<101;y++)
dp[x][y]=200001;
}
for(int x=0;x<n;x++)
dp[x][0]=0;
for(int x=0;x<n-1;x++)
{
tree[bet[x][0]].push_back(make_pair(bet[x][1],w[x]));
tree[bet[x][1]].push_back(make_pair(bet[x][0],w[x]));
}
dfs(0,-1);
if(ans!=200001)
return ans;
return -1;
}
Compilation message
race.cpp: In function 'void dfs(int, int)':
race.cpp:7:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
7 | for(int x=0;x<tree[node].size();x++)
| ~^~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
79320 KB |
Output is correct |
2 |
Correct |
41 ms |
79268 KB |
Output is correct |
3 |
Correct |
50 ms |
79324 KB |
Output is correct |
4 |
Correct |
40 ms |
79260 KB |
Output is correct |
5 |
Correct |
43 ms |
79304 KB |
Output is correct |
6 |
Correct |
39 ms |
79344 KB |
Output is correct |
7 |
Correct |
40 ms |
79316 KB |
Output is correct |
8 |
Correct |
49 ms |
79296 KB |
Output is correct |
9 |
Correct |
40 ms |
79312 KB |
Output is correct |
10 |
Correct |
40 ms |
79260 KB |
Output is correct |
11 |
Correct |
41 ms |
79408 KB |
Output is correct |
12 |
Correct |
40 ms |
79364 KB |
Output is correct |
13 |
Correct |
41 ms |
79260 KB |
Output is correct |
14 |
Correct |
41 ms |
79264 KB |
Output is correct |
15 |
Correct |
40 ms |
79332 KB |
Output is correct |
16 |
Correct |
50 ms |
79360 KB |
Output is correct |
17 |
Correct |
40 ms |
79280 KB |
Output is correct |
18 |
Correct |
41 ms |
79320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
79320 KB |
Output is correct |
2 |
Correct |
41 ms |
79268 KB |
Output is correct |
3 |
Correct |
50 ms |
79324 KB |
Output is correct |
4 |
Correct |
40 ms |
79260 KB |
Output is correct |
5 |
Correct |
43 ms |
79304 KB |
Output is correct |
6 |
Correct |
39 ms |
79344 KB |
Output is correct |
7 |
Correct |
40 ms |
79316 KB |
Output is correct |
8 |
Correct |
49 ms |
79296 KB |
Output is correct |
9 |
Correct |
40 ms |
79312 KB |
Output is correct |
10 |
Correct |
40 ms |
79260 KB |
Output is correct |
11 |
Correct |
41 ms |
79408 KB |
Output is correct |
12 |
Correct |
40 ms |
79364 KB |
Output is correct |
13 |
Correct |
41 ms |
79260 KB |
Output is correct |
14 |
Correct |
41 ms |
79264 KB |
Output is correct |
15 |
Correct |
40 ms |
79332 KB |
Output is correct |
16 |
Correct |
50 ms |
79360 KB |
Output is correct |
17 |
Correct |
40 ms |
79280 KB |
Output is correct |
18 |
Correct |
41 ms |
79320 KB |
Output is correct |
19 |
Correct |
40 ms |
79284 KB |
Output is correct |
20 |
Correct |
40 ms |
79308 KB |
Output is correct |
21 |
Incorrect |
51 ms |
79420 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
79320 KB |
Output is correct |
2 |
Correct |
41 ms |
79268 KB |
Output is correct |
3 |
Correct |
50 ms |
79324 KB |
Output is correct |
4 |
Correct |
40 ms |
79260 KB |
Output is correct |
5 |
Correct |
43 ms |
79304 KB |
Output is correct |
6 |
Correct |
39 ms |
79344 KB |
Output is correct |
7 |
Correct |
40 ms |
79316 KB |
Output is correct |
8 |
Correct |
49 ms |
79296 KB |
Output is correct |
9 |
Correct |
40 ms |
79312 KB |
Output is correct |
10 |
Correct |
40 ms |
79260 KB |
Output is correct |
11 |
Correct |
41 ms |
79408 KB |
Output is correct |
12 |
Correct |
40 ms |
79364 KB |
Output is correct |
13 |
Correct |
41 ms |
79260 KB |
Output is correct |
14 |
Correct |
41 ms |
79264 KB |
Output is correct |
15 |
Correct |
40 ms |
79332 KB |
Output is correct |
16 |
Correct |
50 ms |
79360 KB |
Output is correct |
17 |
Correct |
40 ms |
79280 KB |
Output is correct |
18 |
Correct |
41 ms |
79320 KB |
Output is correct |
19 |
Correct |
115 ms |
86936 KB |
Output is correct |
20 |
Correct |
114 ms |
87908 KB |
Output is correct |
21 |
Correct |
117 ms |
87924 KB |
Output is correct |
22 |
Correct |
118 ms |
88020 KB |
Output is correct |
23 |
Correct |
99 ms |
88128 KB |
Output is correct |
24 |
Correct |
97 ms |
88132 KB |
Output is correct |
25 |
Correct |
111 ms |
92308 KB |
Output is correct |
26 |
Correct |
99 ms |
96692 KB |
Output is correct |
27 |
Correct |
183 ms |
96900 KB |
Output is correct |
28 |
Correct |
172 ms |
114412 KB |
Output is correct |
29 |
Correct |
186 ms |
113032 KB |
Output is correct |
30 |
Correct |
174 ms |
96780 KB |
Output is correct |
31 |
Correct |
171 ms |
96844 KB |
Output is correct |
32 |
Correct |
240 ms |
96864 KB |
Output is correct |
33 |
Correct |
188 ms |
95704 KB |
Output is correct |
34 |
Correct |
110 ms |
96624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
79320 KB |
Output is correct |
2 |
Correct |
41 ms |
79268 KB |
Output is correct |
3 |
Correct |
50 ms |
79324 KB |
Output is correct |
4 |
Correct |
40 ms |
79260 KB |
Output is correct |
5 |
Correct |
43 ms |
79304 KB |
Output is correct |
6 |
Correct |
39 ms |
79344 KB |
Output is correct |
7 |
Correct |
40 ms |
79316 KB |
Output is correct |
8 |
Correct |
49 ms |
79296 KB |
Output is correct |
9 |
Correct |
40 ms |
79312 KB |
Output is correct |
10 |
Correct |
40 ms |
79260 KB |
Output is correct |
11 |
Correct |
41 ms |
79408 KB |
Output is correct |
12 |
Correct |
40 ms |
79364 KB |
Output is correct |
13 |
Correct |
41 ms |
79260 KB |
Output is correct |
14 |
Correct |
41 ms |
79264 KB |
Output is correct |
15 |
Correct |
40 ms |
79332 KB |
Output is correct |
16 |
Correct |
50 ms |
79360 KB |
Output is correct |
17 |
Correct |
40 ms |
79280 KB |
Output is correct |
18 |
Correct |
41 ms |
79320 KB |
Output is correct |
19 |
Correct |
40 ms |
79284 KB |
Output is correct |
20 |
Correct |
40 ms |
79308 KB |
Output is correct |
21 |
Incorrect |
51 ms |
79420 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |