题目链接: Magic boy Bi Luo with his excited tree Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1037 Accepted Submission(s): 298 Problem Description Bi Luo is a magic boy, he also has a migic…
Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are colored white. Consider a set consisting of k (0 ≤ k < n) edges of Appleman's tree. If Appleman deletes these edges from the tree, then…
题目链接: http://codeforces.com/contest/161/problem/D D. Distance in Tree time limit per test 3 secondsmemory limit per test 512 megabytes 问题描述 A tree is a connected graph that doesn't contain any cycles. The distance between two vertices of a tree is th…
Code: #include<bits/stdc++.h> #define ull unsigned long long #define MOD 1000000007 #define ll long long #define maxn 120000 using namespace std; void setIO(string s) { string in=s+".in"; string out=s+".out"; freopen(in.c_str(),&…
B. Appleman and Tree time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are color…
Apple Tree Description Wshxzt is a lovely girl. She likes apple very much. One day HX takes her to an apple tree. There are N nodes in the tree. Each node has an amount of apples. Wshxzt starts her happy trip at one node. She can eat up all the apple…
Apple Tree Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9808 Accepted: 3260 Description Wshxzt is a lovely girl. She likes apple very much. One day HX takes her to an apple tree. There are N nodes in the tree. Each node has an amoun…
Magic boy Bi Luo with his excited tree Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1058 Accepted Submission(s): 308 Problem Description Bi Luo is a magic boy, he also has a migic tree,…
You are given a rooted tree with n nodes. The nodes are numbered 1..n. The root is node 1, and m of the nodes are colored red, the rest are black. You would like to choose a subset of nodes such that there is no node in your subset which is an ancest…
E. Paint the Tree 题目大意:给你一棵树,每一个点都可以染k种颜色,你拥有无数种颜色,每一种颜色最多使用2次,如果一条边的两个节点拥有同一种颜色,那么就说 这条边是饱和的,一个树的价值定义为饱和边的权值之和,问一棵树的最大价值是多少. dp[u][1] 表示这条边用了k种颜色了. dp[u][0] 表示这条边用了k-1种颜色. 子节点往父亲节点转移的时候,这个转移带有一点点的贪心. 首先因为每一个子节点到父亲节点的这条边要不要都会对后面产生影响. 所以我们可以构造一个模型,dp模…