Submission #952010

# Submission time Handle Problem Language Result Execution time Memory
952010 2024-03-23T03:39:27 Z vjudge1 Museum (CEOI17_museum) C++17
0 / 100
21 ms 28508 KB
#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,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]);
	return 0;
}

Compilation message

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 time Memory Grader output
1 Incorrect 1 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 28508 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 28508 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -