随笔分类 - 动态规划—树形dp
摘要:非常nice的题目
阅读全文
摘要:title: A Knapsack Problem date: 2018 11 08 00:07:00 tags: Algorithm mathjax: true 题意 n(1 \leq n \leq 1000)个结点的树,每个结点有重量w和价值v两个属性,现在给你一个大小为$m(1 \
阅读全文
摘要:Problem Description In the battlefield , an effective way to defeat enemies is to break their communication system.The information department told you
阅读全文
摘要:The country Treeland consists of n cities, some pairs of them are connected with unidirectional roads. Overall there are n - 1 roads in the country. W
阅读全文
摘要:You, the leader of Starship Troopers, are sent to destroy a base of the bugs. The base is built underground. It is actually a huge cavern, which consi
阅读全文
摘要:In the new ACM-ICPC Regional Contest, a special monitoring and submitting system will be set up, and students will be able to compete at their own uni
阅读全文
摘要:After Farmer John realized that Bessie had installed a "tree-shaped" network among his N (1 <= N <= 10,000) barns at an incredible cost, he sued Bessi
阅读全文
摘要:Last years Chicago was full of gangster fights and strange murders. The chief of the police got really tired of all these crimes, and decided to arres
阅读全文
摘要:There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure of employees
阅读全文
摘要:A school bought the first computer some time ago(so this computer's id is 1). During the recent years the school bought N-1 new computers. Each new co
阅读全文
摘要:After hearing about the epidemic of obesity in the USA, Farmer John wants his cows to get more exercise, so he has committed to create a bovine marath
阅读全文
摘要:Paladin Manao caught the trail of the ancient Book of Evil in a swampy area. This area contains n settlements numbered from 1 to n. Moving through the
阅读全文
摘要:As you know, an undirected connected graph with n nodes and n - 1 edges is called a tree. You are given an integer d and a tree consisting of n nodes.
阅读全文
摘要:树的最大独立集:对于一颗n个结点的无根树,选出尽量多的结点,使得任何两个结点都不相邻。 题解:dp[ i ][ 0 ~ 1 ]表示以 i 为根结点的子树的最大独立集,0表示不选 i ,1表示选 i 。记 i 的儿子为son。 选 i 的话,其儿子可选可不选,即dp[ i ][ 1 ]+=min(dp
阅读全文