题意:给一个树图,每个点的点权(比如颜色编号),m个询问,每个询问是一个区间[a,b],图中两点之间唯一路径上有多少个不同点权(即多少种颜色)。n 2 #define pii pair 3 #define INF 0x3f3f3f3f 4 #define LL long long 5 usi...
分类:
编程语言 时间:
2015-08-27 18:01:07
阅读次数:
2266
【063-Unique Paths II(唯一路径问题II)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Follow up for “Unique Paths”:
Now consider if some obstacles are added to the grids. How many unique paths would there be?
An...
分类:
编程语言 时间:
2015-08-01 08:52:40
阅读次数:
148
【062-Unique Paths(唯一路径)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).
The robot can only move either down or...
分类:
编程语言 时间:
2015-08-01 07:45:10
阅读次数:
1868
Unique Paths II
Follow up for "Unique Paths":
Now consider if some obstacles are added to the grids. How many unique paths would there be?
An obstacle and empty space is marked as 1 and 0 res...
分类:
其他好文 时间:
2015-07-15 15:05:17
阅读次数:
104
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).
The robot can only move either down or right at any point in time. The robot is trying to reach the ...
分类:
其他好文 时间:
2015-07-15 15:03:19
阅读次数:
137
一、基本术语
节点的度和树的度:树中某个节点的子树的个数称为该节点的度。树中各节点的度的最大值称为树的度,通常将度为m的树称为m次树。分支节点和叶子节点:度不为0的节点称为非终端节点,也叫分支节点。度为0的节点为终端节点或叶子节点。
路径和路径长度:路径长度等于路径所通过的节点数目减1。显然从树的根节点到树中其余节点均存在唯一路径。孩子节点、双亲节点、兄弟节点、子孙节点、祖先节点节点的层次...
分类:
其他好文 时间:
2015-06-15 18:51:06
阅读次数:
132
题意:给一棵树的边标上0或1,求以节点i为源点,其它点到i的唯一路径上的1的边数不超过1条的方案数,输出所有i的答案。思路:令f[i]表示以节点i为源点,只考虑子树i时的方案数,ans[i]为最后答案,fa[i]为i的父亲,则不难得出以下转移方程:f[i] =∏(1 + f[v]),v是i的儿子 ....
分类:
其他好文 时间:
2015-05-27 22:28:42
阅读次数:
193
缓存的实现是以Jar包的方式引入到项目中使用的,之前说过那么Redis服务器的数据源信息就不能配置在Jar包内部,Jar包是不容易更改的。所以,应该将数据源信息配置在外部,即引入的项目中。这样做遇到了两个问题:一是,配置文件的路径,二是,数据源信息唯一。
路径
这个问题上也花费了一点时间,得到了路径很乱。所以,对JAVA的路径做了一点点了解。要读取资源文件,首先需要了解什么是cla...
分类:
其他好文 时间:
2015-05-26 21:22:38
阅读次数:
176
唯一路径问题IIUnique Paths IIFollow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obs...
分类:
其他好文 时间:
2014-11-25 20:21:24
阅读次数:
249
lienhua342014-10-01ISO C 标准 I/O 库提供了个两个函数 tmpnam 和 tmpfile 以帮助创建临时文件,#include char *tmpnam(char *ptr);返回值:指向唯一路径名的指针tmpnam 函数产生一个与现有文件名不同的一个有效路径名字符串。每...
分类:
其他好文 时间:
2014-10-01 17:05:01
阅读次数:
150