Tree
Time Limit: 16000/8000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 41 Accepted Submission(s): 10
Problem Description
You are given a tree wit...
分类:
其他好文 时间:
2014-09-14 09:00:56
阅读次数:
171
前几天用treap写了这一题,不过treap支持的操作不如splay的多,作为一个完美主义者,重新用splay写了这一题。splay大部分操作可以通过强大到无与伦比的数据结构splay-tree然后根据其中步骤写出来。一定要注意的一点:几乎所有操作的背后,都要splay(x, 0)一下。一开始我还以...
分类:
其他好文 时间:
2014-09-14 00:05:16
阅读次数:
384
The xor-longest PathTime Limit:2000MSMemory Limit:65536KTotal Submissions:3875Accepted:850DescriptionIn an edge-weighted tree, the xor-length of a pat...
分类:
其他好文 时间:
2014-09-13 23:59:06
阅读次数:
434
#include
using namespace std;
// 有序二叉树(二叉搜索树)
class Tree {
public:
// 构造过程中初始化为空树
Tree (void) : m_root (NULL), m_size (0) {}
// 析构过程中销毁剩余节点
~Tree (void) {
clear ();
}
// 插入数据
void insert (in...
分类:
其他好文 时间:
2014-09-13 22:52:02
阅读次数:
207
线段树的区间最大值问题,边界特殊处理一下。
#include
#include
#include
#include
#include
#include
using namespace std;
#define maxn 222222
int tree[maxn << 2];
int w,h,m,ok;
void BuildTree(int L,int R,int pos){
tree[p...
分类:
其他好文 时间:
2014-09-13 22:51:26
阅读次数:
206
题意:统计一段序列【L,R】的和,重复元素只算一次。解法:容易看出在线做很难处理重复的情况,干脆全部讲查询读进来,然后将查询根据右端点排个序,然后离散化数据以后就可以操作了。每次读入一个数,如果这个数之前出现过,那么删除之前出现的那个数,改加上这个数,然后进行所有右端点小于等于此时下标的查询即可。关...
分类:
其他好文 时间:
2014-09-13 22:45:56
阅读次数:
207
Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened t...
分类:
其他好文 时间:
2014-09-13 22:39:06
阅读次数:
238
利用线段树在nlogn的时间复杂度内求一段数的逆序。
由于给的序列是由0 ~ n -1组成的,求出初始的逆序之后可以递推出移动之后的逆序数。
#include
#include
#include
#include
using namespace std;
typedef long long LL;
const int maxn = 5555;
int tree[maxn << 2];
int ...
分类:
其他好文 时间:
2014-09-13 21:35:25
阅读次数:
252
刚开始设置Eclipse+Cygwin在Windows下编写LinuxC程序代码,会遇到如下图的问题:解决的办法是:在执行Launcher的时候,先执行Ctrl + b,然后再执行Launcher。
分类:
系统相关 时间:
2014-09-13 21:26:25
阅读次数:
242
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest le...
分类:
其他好文 时间:
2014-09-13 20:08:35
阅读次数:
179