区域查询操作。
ma[i]:i区间内的最大值
mi[i]:i区间内的最小值
#include
#include
#include
#include
#include
using namespace std;
#define INF 99999999
#define lmin 1
#define rmax n
#define lson l,(l+r)/2,rt<<1
#define rson ...
分类:
其他好文 时间:
2014-05-26 04:11:41
阅读次数:
202
点击打开链接
题意:
集合S支持一下四种操作:
INSERT(S,x) : 如果S中没有x,则插入x
DELETE(S,x): 如果S中有x,则删除x
K-TH(S): 输出S中第K小的数
COUNT(S,x): 统计S中小于x的数有多少个
一共有Q(1 ≤ Q ≤ 200000)次操作。
Treap模板。。
#i...
分类:
其他好文 时间:
2014-05-24 18:03:11
阅读次数:
213
1、
??
Balanced Binary Tree
Given a binary tree, determine if it is height-balanced.
For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subt...
分类:
其他好文 时间:
2014-05-23 08:19:19
阅读次数:
282
1、
??
Convert Sorted List to Binary Search Tree
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.
分析:将一个升序排列的链表转换为平衡二叉搜索树,采用递归的方式,先找到链表...
分类:
其他好文 时间:
2014-05-22 12:33:30
阅读次数:
270
比GSS3 麻烦在于要判断两个区间的相交性。
分为三种情况.
1. x1 y1 x2 y2
这种情况就是 x1 y1 的右最大 + sum【y1 x2】 + x2 y2的做最大
2.x1 x2 y2 y1 其实就是 y1==y2的时候
要么区间在 x2-y2之间
要么区间的头在 x1 x2之间,尾在 x2 y2之间
3. x1 x2 y1 y2。
这种情况...
分类:
其他好文 时间:
2014-05-22 11:48:33
阅读次数:
261
戳我去解题Given an array where elements are sorted in
ascending order, convert it to a height balanced
BST.分析:因为BST中序序列是升序的,所以中序遍历序列最中间的元素一定是根节点,然后左右递归构建二叉...
分类:
其他好文 时间:
2014-05-20 11:38:16
阅读次数:
233
Given a binary tree, determine if it is
height-balanced.For this problem, a height-balanced binary tree is defined as a
binary tree in which the depth...
分类:
其他好文 时间:
2014-05-19 20:40:55
阅读次数:
278
题目大意:
给出N个数
0 操作 把 l ----- r之间的数全部开平方
1 操作 输出 l -----r 之间的和
思路分析:
判断区间里的数字是否全相同。如果相同,
将cov 置为该数
查询的时候和更新的时候,如果碰到cov != -1 的 就直接返回就可以了
#include
#include
#include...
分类:
其他好文 时间:
2014-05-18 05:25:06
阅读次数:
227
第四道树题,逐渐能写递归了。虽然最后AC的代码还是看了网络,但是距离成功攻克此类问题仅一步之遥。题目:一棵树,判断是否为AVL。(AVL条件:树上任意一点的左右子树的高度差_
1 ) return false; else return isBalanced(root.lef...
分类:
其他好文 时间:
2014-05-16 04:04:41
阅读次数:
259