# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
791878 | 12345678 | Museum (CEOI17_museum) | C++17 | 643 ms | 784784 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 <bits/stdc++.h>
using namespace std;
const int nx=1e4+5;
int n, k, x, dp[2][nx][nx], u, v, w, cnt[nx];
vector<vector<pair<int, int>>> d(nx);
void dfs(int u, int p)
{
cnt[u]=1; dp[0][u][1]=dp[1][u][1]=0;
for (auto [v, w]:d[u])
{
if (v==p) continue;
dfs(v, u);
for (int i=cnt[u]; i>=0; i--)
{
for (int j=cnt[v]; j>=1; j--)
{
dp[0][u][i+j]=min(dp[0][u][i+j], dp[0][u][i]+dp[0][v][j]+2*w);
dp[1][u][i+j]=min(dp[1][u][i+j], dp[1][u][i]+dp[0][v][j]+2*w);
dp[1][u][i+j]=min(dp[1][u][i+j], dp[0][u][i]+dp[1][v][j]+w);
}
}
cnt[u]+=cnt[v];
}
}
int main()
{
# | 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... |