
数据结构_伸展树
文章平均质量分 81
SCUT_Pein
这个作者很懒,什么都没留下…
展开
-
AHOI2006
#include#include#include#include#include#define N 1024*1024*2#define inf 1<<29#define MOD 100000007#define LL long long#define Key_value ch[ch[root][1]][0]#define _match(a,b) ((a)=原创 2014-02-07 14:24:33 · 747 阅读 · 0 评论 -
大视野1500--splay
DescriptionInput输入文件的第1行包含两个数N和M,N表示初始时数列中数的个数,M表示要进行的操作数目。第2行包含N个数字,描述初始时的数列。以下M行,每行一条命令,格式参见问题描述中的表格。Output对于输入数据中的GET-SUM和MAX-SUM操作,向输出文件依次打印结果,每个答案(数字)占一行。Sample Input9 8原创 2014-07-19 13:39:59 · 597 阅读 · 0 评论 -
POJ2761--Feed the dogs
DescriptionWind loves pretty dogs very much, and she has n pet dogs. So Jiajia has to feed the dogs every day for Wind. Jiajia loves Wind, but not the dogs, so Jiajia use a special way to feed the d原创 2013-11-14 21:32:13 · 1152 阅读 · 0 评论 -
HDU1890
#include#include#includeusing namespace std;#define Keytree (ch[ ch[root][1] ][0])const int maxn = 100010;struct node { int num,id;}in[maxn];int id[maxn];int cmp(node a,node b){原创 2014-02-07 13:03:50 · 888 阅读 · 0 评论 -
UVa 11996 Jewel Magic 伸展树
I am a magician. I have a string of emeralds and pearls. I may insert new jewels in the string, or remove old ones. I may even reverse a consecutive part of the string. At anytime, if you point to two原创 2014-02-27 18:58:18 · 1114 阅读 · 0 评论 -
Lights--ZOJ月赛--伸展树
Now you have N lights in a line. Don't worry - the lights don't have color. The only status they have is on and off. And, each light has a value, too.There is a boring student in ZJU. He decides t原创 2014-03-02 19:44:59 · 791 阅读 · 0 评论 -
HNOI2002--Splay
将每一个依次插入,与前驱和后继进行比较,选取差值小的。如果遇到相同的数已经在树中,则不插入。#include #include #include using namespace std;#define maxn 100010#define inf 0x3f3f3f3fint pre[maxn],key[maxn],ch[maxn][2],root,tot1;int原创 2014-02-06 14:54:52 · 748 阅读 · 0 评论 -
POJ3580
#include#include#include#include#include#define N 200005#define inf 1<<29#define MOD 100000007#define LL long long#define Key_value ch[ch[root][1]][0]#define _match(a,b) ((a)==(b))原创 2014-02-07 14:40:56 · 648 阅读 · 0 评论 -
HDU3487
#include#include#include#include#include#define N 300015#define inf 1<<29#define MOD 100000007#define LL long long#define Key_value ch[ch[root][1]][0]#define _match(a,b) ((a)==(b))原创 2014-02-07 13:38:13 · 823 阅读 · 0 评论 -
HDU3436
#include#include#include#include#define N 100015#define inf 1<<29#define LL long long#define Key_value ch[ch[root][1]][0]using namespace std;int n,q,p[N],cnt,s[2*N],e[2*N],ope[N];i原创 2014-02-07 13:33:55 · 834 阅读 · 0 评论 -
UVA 11922 Permutation Transformer 伸展树
Write a program to transform the permutation 1, 2, 3,..., n according to m instructions. Each instruction(a, b) means to take out the subsequence from the a-th to the b-th element, reverse it, then原创 2014-02-25 22:07:02 · 899 阅读 · 0 评论 -
POJ3468
#include #include #include using namespace std;#define maxn 100010#define inf 0x3f3f3f3f#define LL long long int#define Key_value ch[ch[root][1]][0]int pre[maxn],key[maxn],ch[maxn][2],原创 2014-02-06 15:51:08 · 909 阅读 · 0 评论 -
NOI2005
#include#include#include#include#include#define N 500005#define inf 1<<29#define MOD 100000007#define LL long long#define Key_value ch[ch[root][1]][0]#define _match(a,b) ((a)==(b))原创 2014-02-07 14:35:15 · 667 阅读 · 0 评论 -
大视野1503-- [NOI2004]郁闷的出纳员SPLAY
DescriptionOIER公司是一家大型专业化软件公司,有着数以万计的员工。作为一名出纳员,我的任务之一便是统计每位员工的工资。这本来是一份不错的工作,但是令人郁闷的是,我们的老板反复无常,经常调整员工的工资。如果他心情好,就可能把每位员工的工资加上一个相同的量。反之,如果心情不好,就可能把他们的工资扣除一个相同的量。我真不知道除了调工资他还做什么其它事情。工资的频繁调整很让员工反感,原创 2014-07-25 13:28:01 · 739 阅读 · 0 评论