原题地址:http://oj.leetcode.com/problems/binary-tree-level-order-traversal/题意:二叉树的层序遍历的实现。解题思路:二叉树的层序遍历可以用bfs或者dfs来实现。这里使用的dfs实现,代码比较简洁。实际上,二叉树的先序遍历就是dfs实...
分类:
编程语言 时间:
2014-05-14 03:25:59
阅读次数:
428
Continuous Login
Time Limit: 2 Seconds Memory Limit: 131072 KB Special Judge
Pierre is recently obsessed with an online game. To encourage users to log in, this game will give user...
分类:
其他好文 时间:
2014-05-14 01:25:00
阅读次数:
396
Gao The SequenceTime Limit:2 Seconds Memory
Limit:65536 KBYou are given a sequence of integers,A1,A2,...,An. And you are
allowed a manipulation on the...
分类:
其他好文 时间:
2014-05-13 19:49:14
阅读次数:
277
思路分析:
遗憾不知道矩阵的构造。线段树上比较水的矩阵。。。
M[x] = [1 A[x]]
[1 0 ]
就有
[ F[R] ] = M[R] * M[R-1] * ... * M[L+2] * [F[L+1]]
[F[R-1]] ...
分类:
其他好文 时间:
2014-05-13 08:45:03
阅读次数:
270
题目链接:点击打开链接
题意:给定n*m的矩阵
有一个人a从左上角↖走到右下角↘,只能↓或→走
另一个人b从左下角↙走到右上角↗,只能↑或→走
使得2个人的路径有且仅有一个格子是相交的。
统计2个人的权值和(相交格子的权值和不计)
问最大的权值和是多少。
思路:
首先转换一下题意,也就是找一个格子与4个角落连不相交的线。
我们观察相交的那个格子,那个格子的上下左右必然对应着一个角...
分类:
其他好文 时间:
2014-05-13 07:51:44
阅读次数:
280
题目链接:
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3768
Continuous Login
Time Limit: 2 Seconds Memory Limit: 131072 KB Special Judge
Pierre is recently obsessed...
分类:
其他好文 时间:
2014-05-13 07:28:07
阅读次数:
412
链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=151
For each list of words, output a line with each word reversed without changing the order of the words.
This problem contains multi...
分类:
其他好文 时间:
2014-05-11 22:20:43
阅读次数:
443
链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1109
FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBean...
分类:
其他好文 时间:
2014-05-11 20:57:36
阅读次数:
400
链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2724
Message queue is the basic fundamental of windows system. For each process, the system maintains a message queue. If something h...
题目链接:
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=729
题目意思:...
分类:
其他好文 时间:
2014-05-11 01:52:41
阅读次数:
367