제출 #236480

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
2364802020-06-02 11:41:24MohamedAhmed04Museum (CEOI17_museum)C++14
100 / 100
821 ms746360 KiB
#include <bits/stdc++.h>
using namespace std ;
const int MAX = 1e4 + 2 ;
int n , k , x ;
vector< vector< pair<int , int> > >adj(MAX) ;
int sz[MAX] ;
int dp[MAX][MAX][2] , tmp[MAX][2] ;
void dfs(int node , int par)
{
dp[node][1][0] = dp[node][1][1] = 0 ;
sz[node] = 1 ;
for(auto &childd : adj[node])
{
int child = childd.first , cost = childd.second ;
if(child == par)
continue ;
dfs(child , node) ;
for(int k1 = 0 ; k1 <= min(sz[node] , k) ; ++k1)
{
for(int k2 = 0 ; k2 <= sz[child] && k1 + k2 <= k ; ++k2)
{
tmp[k1+k2][0] = min(tmp[k1+k2][0] , dp[node][k1][0] + dp[child][k2][0] + 2 * cost) ;
tmp[k1+k2][1] = min(tmp[k1+k2][1] , dp[node][k1][0] + dp[child][k2][1] + cost) ;
tmp[k1+k2][1] = min(tmp[k1+k2][1] , dp[node][k1][1] + dp[child][k2][0] + 2 * cost) ;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
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...