# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
244178 |
2020-07-02T17:42:51 Z |
bigg |
Race (IOI11_race) |
C++14 |
|
117 ms |
55672 KB |
#include "race.h"
#include<bits/stdc++.h>
using namespace std;
std::vector<pair<int,int> > grafo[212345];
int marc[212345];
int dp[212345][112];
int k;
void dfs(int x){
marc[x] = 1;
dp[x][0] = 0;
for(int i = 0; i < grafo[x].size(); i++){
int viz = grafo[x][i].first;
if(marc[viz]) continue;
dfs(viz);
for(int j = grafo[x][i].second; j <= k; j++){
// printf("%d %d %d\n",x, j, dp[x][j] );
dp[x][j] = min(dp[x][j], dp[viz][j - grafo[x][i].second] + 1);
}
}
}
int INF = 1e9;
int n;
int best_path(int N, int K, int H[][2], int L[])
{ n = N;
k = K;
for(int i = 0; i < N - 1; i++){
int u, v, w;
// scanf("%d %d %d", &u, &v, &w);
u = H[i][0];
v = H[i][1];
w = L[i];
grafo[u].push_back(make_pair(v, w));
grafo[v].push_back(make_pair(u, w));
}
for(int i = 0; i < n; i++){
for(int j = 1; j <= 100; j++){
dp[i][j] = INF;
}
}
dfs(0);
int ans = 1e9;
for(int i = 0; i < n; i++){
//printf("%d\n",dp[i][k] );
ans = min(ans, dp[i][k]);
}
if(ans >= INF) ans = -1;
return ans;
}
Compilation message
race.cpp: In function 'void dfs(int)':
race.cpp:11:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < grafo[x].size(); i++){
~~^~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
5376 KB |
Output is correct |
2 |
Correct |
7 ms |
5376 KB |
Output is correct |
3 |
Correct |
8 ms |
5376 KB |
Output is correct |
4 |
Correct |
8 ms |
5376 KB |
Output is correct |
5 |
Correct |
8 ms |
5376 KB |
Output is correct |
6 |
Correct |
8 ms |
5376 KB |
Output is correct |
7 |
Correct |
8 ms |
5504 KB |
Output is correct |
8 |
Correct |
7 ms |
5376 KB |
Output is correct |
9 |
Correct |
8 ms |
5376 KB |
Output is correct |
10 |
Correct |
7 ms |
5376 KB |
Output is correct |
11 |
Correct |
8 ms |
5376 KB |
Output is correct |
12 |
Correct |
8 ms |
5376 KB |
Output is correct |
13 |
Correct |
8 ms |
5376 KB |
Output is correct |
14 |
Correct |
8 ms |
5376 KB |
Output is correct |
15 |
Correct |
7 ms |
5376 KB |
Output is correct |
16 |
Correct |
7 ms |
5376 KB |
Output is correct |
17 |
Correct |
9 ms |
5376 KB |
Output is correct |
18 |
Correct |
8 ms |
5376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
5376 KB |
Output is correct |
2 |
Correct |
7 ms |
5376 KB |
Output is correct |
3 |
Correct |
8 ms |
5376 KB |
Output is correct |
4 |
Correct |
8 ms |
5376 KB |
Output is correct |
5 |
Correct |
8 ms |
5376 KB |
Output is correct |
6 |
Correct |
8 ms |
5376 KB |
Output is correct |
7 |
Correct |
8 ms |
5504 KB |
Output is correct |
8 |
Correct |
7 ms |
5376 KB |
Output is correct |
9 |
Correct |
8 ms |
5376 KB |
Output is correct |
10 |
Correct |
7 ms |
5376 KB |
Output is correct |
11 |
Correct |
8 ms |
5376 KB |
Output is correct |
12 |
Correct |
8 ms |
5376 KB |
Output is correct |
13 |
Correct |
8 ms |
5376 KB |
Output is correct |
14 |
Correct |
8 ms |
5376 KB |
Output is correct |
15 |
Correct |
7 ms |
5376 KB |
Output is correct |
16 |
Correct |
7 ms |
5376 KB |
Output is correct |
17 |
Correct |
9 ms |
5376 KB |
Output is correct |
18 |
Correct |
8 ms |
5376 KB |
Output is correct |
19 |
Incorrect |
7 ms |
5376 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
5376 KB |
Output is correct |
2 |
Correct |
7 ms |
5376 KB |
Output is correct |
3 |
Correct |
8 ms |
5376 KB |
Output is correct |
4 |
Correct |
8 ms |
5376 KB |
Output is correct |
5 |
Correct |
8 ms |
5376 KB |
Output is correct |
6 |
Correct |
8 ms |
5376 KB |
Output is correct |
7 |
Correct |
8 ms |
5504 KB |
Output is correct |
8 |
Correct |
7 ms |
5376 KB |
Output is correct |
9 |
Correct |
8 ms |
5376 KB |
Output is correct |
10 |
Correct |
7 ms |
5376 KB |
Output is correct |
11 |
Correct |
8 ms |
5376 KB |
Output is correct |
12 |
Correct |
8 ms |
5376 KB |
Output is correct |
13 |
Correct |
8 ms |
5376 KB |
Output is correct |
14 |
Correct |
8 ms |
5376 KB |
Output is correct |
15 |
Correct |
7 ms |
5376 KB |
Output is correct |
16 |
Correct |
7 ms |
5376 KB |
Output is correct |
17 |
Correct |
9 ms |
5376 KB |
Output is correct |
18 |
Correct |
8 ms |
5376 KB |
Output is correct |
19 |
Incorrect |
117 ms |
55672 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
5376 KB |
Output is correct |
2 |
Correct |
7 ms |
5376 KB |
Output is correct |
3 |
Correct |
8 ms |
5376 KB |
Output is correct |
4 |
Correct |
8 ms |
5376 KB |
Output is correct |
5 |
Correct |
8 ms |
5376 KB |
Output is correct |
6 |
Correct |
8 ms |
5376 KB |
Output is correct |
7 |
Correct |
8 ms |
5504 KB |
Output is correct |
8 |
Correct |
7 ms |
5376 KB |
Output is correct |
9 |
Correct |
8 ms |
5376 KB |
Output is correct |
10 |
Correct |
7 ms |
5376 KB |
Output is correct |
11 |
Correct |
8 ms |
5376 KB |
Output is correct |
12 |
Correct |
8 ms |
5376 KB |
Output is correct |
13 |
Correct |
8 ms |
5376 KB |
Output is correct |
14 |
Correct |
8 ms |
5376 KB |
Output is correct |
15 |
Correct |
7 ms |
5376 KB |
Output is correct |
16 |
Correct |
7 ms |
5376 KB |
Output is correct |
17 |
Correct |
9 ms |
5376 KB |
Output is correct |
18 |
Correct |
8 ms |
5376 KB |
Output is correct |
19 |
Incorrect |
7 ms |
5376 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |