# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1004895 | cpdreamer | Race (IOI11_race) | C++14 | 2 ms | 13144 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "race.h"
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
vector<pair<int, int>> adj[300005];
int dp[300005][105];
void dfs(int node, int parent, int K) {
dp[node][0] = 0; // Distance to self with 0 jumps is 0
for (auto &edge : adj[node]) {
int next = edge.first;
int length = edge.second;
if (next == parent) continue;
dfs(next, node, K);
for (int j = K; j >= 0; --j) {
if (dp[node][j] == INF) continue;
for (int l = 1; l + j <= K; ++l) {
if (dp[next][l] != INF) {
dp[node][j + l] = min(dp[node][j + l], dp[node][j] + dp[next][l] + length);
}
}
}
}
}
int best_path(int N, int K, int H[][2], int L[]) {
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |