题意:
给定一棵n(2000)个节点的树 每个节点上有个数字 问 有多少棵子树满足树中最大数字与最小数字的差不超过d
思路:
根据数据猜复杂度可能为n^2 想到尝试树形dp
假如枚举现在树中的最大值 那么最小值可以求出 这时不在数值范围内的节点都可以标记掉
那么假设这个最大值的点我一定选取 那么就可以dp出一定选这个点的情况下子树的种类数
假设u是父节点 v是子节点...
分类:
其他好文 时间:
2014-11-21 21:56:47
阅读次数:
212
Longest Valid ParenthesesGiven a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses sub...
分类:
其他好文 时间:
2014-11-21 20:31:10
阅读次数:
235
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the lon...
分类:
其他好文 时间:
2014-11-21 14:00:49
阅读次数:
172
Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another express...
分类:
其他好文 时间:
2014-11-21 12:15:28
阅读次数:
149
ProblemIn 1-9 keypad one key is not working. If someone enters a password then not working key will not be entered. You have given expected password a...
分类:
其他好文 时间:
2014-11-21 06:58:11
阅读次数:
197
ProblemPrint all valid phone numbers of length n subject to following constraints:If a number contains a 4, it should start with 4No two consecutive d...
分类:
其他好文 时间:
2014-11-21 06:54:39
阅读次数:
149
Evaluate Reverse Polish NotationEvaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may ...
分类:
其他好文 时间:
2014-11-20 20:11:18
阅读次数:
177
题目:就是判断已有的数字是否冲突无效,若无效返回flase 有效返回true 不要求sudo可解用了char型的数字,并且空格用‘.'来表示的。思路:只要分别判断横向 竖向 3*3小块中的数字是否有重复或者无效就可以了 就是单纯的麻烦 不难#include#includeusing namespac...
分类:
其他好文 时间:
2014-11-20 13:24:15
阅读次数:
160
centos yum 错误 Error: Cannot find a valid baseurl for repo: addons 装了个CentOS 6.5,使用yum时出现了下面的错误提示。
[root@localhost ~]# yum install lrzsz
Loaded plugins: fastestmirror
Determining fastest mirrors
Co...
分类:
Web程序 时间:
2014-11-19 16:07:35
阅读次数:
223
Question:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close...
分类:
其他好文 时间:
2014-11-19 10:33:46
阅读次数:
142