Submission #951994

#TimeUsernameProblemLanguageResultExecution timeMemory
951994vjudge1Museum (CEOI17_museum)C++17
0 / 100
20 ms28508 KiB
#include<bits/stdc++.h> using namespace std; const int MAXN=10005; int n,m,x,son[MAXN],dp[MAXN][MAXN]; struct node{int to,cost;}; vector<node>g[MAXN]; void dfs(int u,int fa){ for(auto i:g[u]){ int v=i.to; if(v==fa) continue; dfs(v,u);son[u]+=son[v]+1; for(int j=min(m-1,son[u]);j>=0;j--) for(int k=min(j-1,son[v]);k>=0;k--) dp[u][j]=max(dp[u][j],dp[u][j-k-1]+dp[v][k]+i.cost); } } int main(){ scanf("%d%d%d",&n,&m,&x); for(int i=1;i<=n-1;i++){ int u,v,c;scanf("%d%d%d",&u,&v,&c); g[u].push_back({v,c}); g[v].push_back({u,c}); } dfs(x,0); printf("%d",dp[x][m-1]); return 0;; }

Compilation message (stderr)

museum.cpp: In function 'int main()':
museum.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     scanf("%d%d%d",&n,&m,&x);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
museum.cpp:20:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |      int u,v,c;scanf("%d%d%d",&u,&v,&c);
      |                ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...