# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
236483 | MohamedAhmed04 | Museum (CEOI17_museum) | C++14 | 399 ms | 181032 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 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] + (k2 > 0) * 2 * cost) ;
tmp[k1+k2][1] = min(tmp[k1+k2][1] , dp[node][k1][0] + dp[child][k2][1] + (k2 > 0) * cost) ;
tmp[k1+k2][1] = min(tmp[k1+k2][1] , dp[node][k1][1] + dp[child][k2][0] + (k2 > 0) * 2 * cost) ;
# | 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... |