| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 561559 | piOOE | Road Closures (APIO21_roads) | C++17 | 201 ms | 31860 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "roads.h"
#include <bits/stdc++.h>
using namespace std;
#define all(x) begin(x), end(x)
typedef long long ll;
const int N = 2001;
int A[N], B[N], W[N], n;
ll dp[N][N];
vector <pair<int, int>> g[N];
void dfs(int v, int p) {
vector<pair<int, int>> adj;
for (auto [to, w]: g[v]) {
if (to != p) {
dfs(to, v);
adj.emplace_back(to, w);
}
}
for (int k = 0; k < n; ++k) {
if (k > size(adj)) {
dp[v][k] = dp[v][k - 1];
continue;
}
vector<ll> nw;
ll ans = 0;
for (auto [to, w]: adj) {
ans += dp[to][k] + w;
if (k) {
nw.push_back(dp[to][k - 1] - dp[to][k] - w);
}
}
sort(all(nw));
for (int i = 0; i < k; ++i) {
if (nw[i] < 0)
ans += nw[i];
}
dp[v][k] = ans;
if (k) {
dp[v][k] = min(dp[v][k], dp[v][k - 1]);
}
}
}
vector <ll> minimum_closure_costs(int nn, vector<int> uu, vector<int> vv, vector<int> ww) {
n = nn;
for (int i = 0; i < n - 1; ++i) {
A[i] = uu[i], B[i] = vv[i], W[i] = ww[i];
g[A[i]].emplace_back(B[i], W[i]);
g[B[i]].emplace_back(A[i], W[i]);
}
vector <ll> ans;
dfs(0, -1);
for (int i = 0; i < n; ++i) {
ans.push_back(dp[0][i]);
}
return ans;
}
컴파일 시 표준 에러 (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... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
