Submission #155710

# Submission time Handle Problem Language Result Execution time Memory
155710 2019-09-30T03:26:20 Z Fischer Museum (CEOI17_museum) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 2;
struct Node {
	int v, w;
};
vector<Node> g[maxn];
int n, k, x;
int sz[maxn];
int memo[maxn][maxn][2];

void dfs(int x, int p) {
	sz[x] = 1;
	for (auto node : g[x]) {
		if (node.v == p) continue;
		dfs(node.v, x);
		sz[x] += sz[node.v];
	}
	memo[x][1][0] = memo[x][1][1] = 0; 
	for (auto node : g[x]) {
		if (node.v == p) continue;
		for (int i = min(sz[x], k); i >= 2; --i) {
			for (int j = min(sz[node.v], i-1); j >= 1; --j) {
				memo[x][i][1] = min(memo[x][i][1],
					min(
						memo[x][i-j][1] + memo[node.v][j][0] + (node.w<<1),
						memo[x][i-j][0] + memo[node.v][j][1] + node.w
					));
				memo[x][i][0] = min(memo[x][i][0], 
					memo[x][i-j][0] + memo[node.v][j][0] + (node.w<<1));
			}
		}
	}
}

int main() {
	cin >> n >> k >> x;
	for (int i = 1; i <= n-1; ++i) {
		int a, b, c;
		cin >> a >> b >> c;
		g[a].push_back({b, c});
		g[b].push_back({a, c});
	}
	memset(memo, 63, sizeof memset);
	dfs(x, 0);
	cout << memo[x][k][1] << endl;
	return 0;
}

Compilation message

museum.cpp: In function 'int main()':
museum.cpp:44:26: error: ISO C++ forbids applying 'sizeof' to an expression of function type [-fpermissive]
  memset(memo, 63, sizeof memset);
                          ^~~~~~