| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1112852 | kiethm07 | 경주 (Race) (IOI11_race) | C++11 | 410 ms | 104008 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <race.h>
#define pii pair<int,int>
#define iii pair<int,pii>
#define fi first
#define se second
#define vi vector<int>
#define all(x) x.begin(),x.end()
#define TEXT "a"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int inf = 1e9 + 7;
const ld eps = 1e-8;
const double pi = acos(-1);
const int N = 2e5 + 5;
vector<pii> a[N];
int n;
ll k;
map<ll,int> mp[N];
int h[N], sz[N];
ll f[N];
int combine(int u,map<ll,int>& a, map<ll,int>& b){
int res = inf;
for (pii p : b){
auto tmp = a.find(k - p.fi + 2 * f[u]);
if (tmp == a.end()) continue;
res = min(res, p.second + tmp->second - 2 * h[u]);
}
for (pii p : b){
if (a.find(p.fi) != a.end()) a[p.fi] = min(a[p.fi], p.se);
else a[p.fi] = p.se;
}
return res;
}
int dfs(int u,int p = -1){
int res = inf;
for (int i = 0; i < a[u].size(); i++){
int v = a[u][i].fi;
int w = a[u][i].se;
if (v == p) continue;
h[v] = h[u] + 1;
f[v] = f[u] + w;
mp[v][f[v]] = h[v];
int tmp = dfs(v,u);
res = min(res, tmp);
if (mp[u].size() < mp[v].size()) swap(mp[u], mp[v]);
res = min(res, combine(u,mp[u],mp[v]));
}
return res;
}
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 = H[i][0] + 1;
int v = H[i][1] + 1;
int w = L[i];
a[u].push_back(pii(v,w));
a[v].push_back(pii(u,w));
}
int res = dfs(1,-1);
if (res == inf) res = -1;
return res;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
