# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28930 | h0ngjun7 | Race (IOI11_race) | C++14 | 518 ms | 66484 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 <vector>
#include <algorithm>
#include <unordered_map>
using namespace std;
const int MAXN = 200005;
struct EDGE { int x, w; };
int N, K, ans = -1;
vector <EDGE> v[MAXN];
void f(int x, int par, unordered_map <int, int> &d, int &L, int &W) {
d[0] = 0;
for (auto &y : v[x]) {
if (y.x == par) continue;
unordered_map <int, int> d2;
int L2 = 0, W2 = 0;
f(y.x, x, d2, L2, W2);
L2++; W2 += y.w;
if (d.size() < d2.size()) {
d.swap(d2);
swap(L, L2);
swap(W, W2);
}
for (auto &t : d2) {
if (d.count(K - (t.first + W2 + W))) {
if (ans == -1 || ans > d[K - (t.first + W2 + W)] + t.second + L + L2)
ans = d[K - (t.first + W2 + W)] + t.second + L + L2;
}
}
# | 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... |