采用一维数组建树。(因为一维数组建的是完全二叉树,时间上比用孩子节点指针建树慢,不过基本可以忽略=-=)
#include
#include
#include
using namespace std;
const int INF = 0xffffff0;
int minV=INF;
int maxV=-INF;
struct Node
{
    int L,R;
    int minV,ma...
                            
                            
                                分类:
其他好文   时间:
2014-07-20 22:28:44   
                                阅读次数:
216
                             
                    
                        
                            
                            
                                Balanced Lineup
Time Limit: 5000MS
 
Memory Limit: 65536K
Total Submissions: 33094
 
Accepted: 15552
Case Time Limit: 2000MS
Description
For the daily milking, Far...
                            
                            
                                分类:
其他好文   时间:
2014-07-18 17:09:01   
                                阅读次数:
225
                             
                    
                        
                            
                            
                                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-07-18 09:33:38   
                                阅读次数:
194
                             
                    
                        
                            
                            
                                本文出自:http://blog.csdn.net/svitter
题意:在1~200,000个数中,取一段区间,然后在区间中找出最大的数和最小的数字,求这两个数字的差。
分析:按区间取值,很明显使用的线段树。区间大小取200000 * 4 = 8 * 10 ^5;
          进行查询的时候,注意直接判断l, r 与mid的关系即可,一开始写的时候直接与tree[root]...
                            
                            
                                分类:
其他好文   时间:
2014-07-15 12:22:14   
                                阅读次数:
268
                             
                    
                        
                            
                            
                                Balanced Lineup
Time Limit: 5000MS
 
Memory Limit: 65536K
Total Submissions: 32778
 
Accepted: 15425
Case Time Limit: 2000MS
Description
For the daily milking, Far...
                            
                            
                                分类:
其他好文   时间:
2014-07-14 12:44:18   
                                阅读次数:
194
                             
                    
                        
                            
                            
                                B. Balanced LineupTime Limit:5000msCase Time Limit:5000msMemory Limit:65536KB64-bit integer IO format:%lld Java class name:MainFor the daily milking, ...
                            
                            
                                分类:
其他好文   时间:
2014-07-13 19:40:47   
                                阅读次数:
227
                             
                    
                        
                            
                            
                                链接:http://poj.org/problem?id=3264Time Limit:5000MSMemory Limit:65536KTotal Submissions:32772Accepted:15421Case Time Limit:2000MSDescriptionFor the dai...
                            
                            
                                分类:
其他好文   时间:
2014-07-13 19:35:19   
                                阅读次数:
234
                             
                    
                        
                            
                            
                                ST算法即是sparse table算法,就是稀疏表的意思,就是利用二分法来划分一个表,划分为2的次方段,之后利用这个st表计算查询结果,可以使得预处理时间O(nlgn),而查询时间为O(1) ;
那么有人会有疑问,既然查询时间是O(1),那么为什么这个算法很多时候并不比线段树快多少,甚至根本没有快过呢?
因为其实查询时间为O(log(range)), range为查询区间的大小,因为...
                            
                            
                                分类:
其他好文   时间:
2014-07-12 20:35:55   
                                阅读次数:
164
                             
                    
                        
                            
                            
                                Balanced Number
Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)
Total Submission(s): 1871    Accepted Submission(s): 836
Problem Description
A balanced...
                            
                            
                                分类:
其他好文   时间:
2014-07-09 11:54:01   
                                阅读次数:
187
                             
                    
                        
                            
                            
                                [LeetCode]Balanced Binary Tree...
                            
                            
                                分类:
其他好文   时间:
2014-07-04 07:54:30   
                                阅读次数:
199