# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
416296 | DEQK | 경주 (Race) (IOI11_race) | C++17 | 380 ms | 79992 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "race.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 500500;
ll ans = 1e9;
ll d[N], K;
ll len[N];
vector<pair<int, int>> g[N];
void calc(int u,int p,ll x = 0) {
len[u] = x;
for(auto to : g[u]) if(to.first != p) {
d[to.first] = d[u] + 1;
calc(to.first, u, x + to.second);
}
}
map<ll, ll> dfs(int u,int p) {
map<ll, ll> own;
own[len[u]] = d[u];
for(auto to : g[u]) if(to.first != p) {
auto x = dfs(to.first, u);
if(x.size() > own.size()) {
own.swap(x);
}
for(auto it : x) {
if(own.count(K - it.first + 2 * len[u])) {
ans = min(ans, own[K - it.first + 2 * len[u]] + it.second - 2 * d[u]);
}
if(own.count(it.first)) {
own[it.first] = min(own[it.first], it.second);
# | 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... |