题目:hdoj1166
分析:题意很清晰,就是让你给某个点又增加或者减少x个,然后求某一段有多少个,我是用一个father数组保存叶子节点的编号,然后直接从当前节点开始,更轻到root就ok。
查询的话,从根节点开始,看在左子区间还是右子区间,直接查询到某一段全部在要查询的区间内,求和就ok,很简单。
代码:
#include
#include
#include
...
分类:
其他好文 时间:
2014-07-22 14:33:54
阅读次数:
231
题目:hdoj1754 I Hate It
分析:更新的话,建树的时候保存叶子编号的的节点信息,然后从下往上更新就ok。
求和的话,从根节点开始,然后找在根的左边还是右边,然后递归找一个所有中的最大值即可、
代码:
#include
#include
#include
using namespace std;
const int N = 205000;
struct...
分类:
其他好文 时间:
2014-07-22 14:33:36
阅读次数:
179
algorithm之min_element()与max_element()...
分类:
其他好文 时间:
2014-07-22 14:17:49
阅读次数:
172
题目:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorte....
分类:
编程语言 时间:
2014-07-22 00:35:34
阅读次数:
290
Given an array of integers, every element appearsthreetimes except for one. Find that single one.Note:Your algorithm should have a linear runtime comp...
分类:
其他好文 时间:
2014-07-22 00:28:38
阅读次数:
209
Quicksum时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte总提交:615 测试通过:256描述A checksum is an algorithm that scans a packet of data and returns a s...
分类:
其他好文 时间:
2014-07-22 00:25:37
阅读次数:
249
Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the ord...
分类:
其他好文 时间:
2014-07-22 00:13:35
阅读次数:
154
Description
The cows have a line of 20 water bowls from which they drink. The bowls can be either right-side-up (properly oriented to serve refreshing cool water) or upside-down (a position which h...
分类:
其他好文 时间:
2014-07-21 22:32:18
阅读次数:
278
2804:词典
总时间限制: 3000ms 内存限制: 65536kB
描述
你旅游到了一个国外的城市。那里的人们说的外国语言你不能理解。不过幸运的是,你有一本词典可以帮助你。
输入
首先输入一个词典,词典中包含不超过100000个词条,每个词条占据一行。每一个词条包括一个英文单词和一个外语单词,两个单词之间用一个空格隔开。而且在词典中不会有某个外语单...
分类:
其他好文 时间:
2014-07-21 16:23:12
阅读次数:
237
http://acm.hdu.edu.cn/showproblem.php?pid=3397
Sequence operation
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 5801 Accepted Subm...
分类:
其他好文 时间:
2014-07-21 11:45:44
阅读次数:
244