Submission #791878

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
7918782023-07-24 12:02:1712345678Museum (CEOI17_museum)C++17
100 / 100
643 ms784784 KiB
#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()
{
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...