BZOJ 1269: [AHOI2006]文本编辑器editor 分离合并Splay

用Ubuntu 22.04和VMware Workstation搭建你的第一个软路由(保姆级教程) 本文提供了一份详细的Ubuntu 22.04和VMware Workstation搭建软路由的保姆级教程。通过IP Forwarding和路由转发技术,读者可以轻松构建高性能软路由,提升网络吞吐量和连接数上限,适用于家庭和办公环境。教程涵盖环境搭建、系统配置、防火墙安全及高级功能扩展,帮助用户充分利用闲置设备实现网络优化。 阅读详情

这些日子,可可不和卡卡一起玩了,原来可可正废寝忘食的想做一个简单而高效的文本编辑器。你能帮助他吗?为了明确任务目标,可可对“文本编辑器”做了一个抽象的定义:

这里写图片描述

这里写图片描述

文本:由0个或多个字符构成的序列。这些字符的ASCII码在闭区间[32, 126]内,也就是说,这些字符均为可见字符或空格。光标:在一段文本中用于指示位置的标记,可以位于文本的第一个字符之前,文本的最后一个字符之后或文本的某两个相邻字符之间。文本编辑器:为一个可以对一段文本和该文本中的一个光标进行如下七条操作的程序。如果这段文本为空,我们就说这个文本编辑器是空的。 编写一个程序: 建立一个空的文本编辑器。 从输入文件中读入一些操作指令并执行。 对所有执行过的GET操作,将指定的内容写入输出文件。
Input

输入文件中第一行是指令条数N,以下是需要执行的N个操作。除了回车符之外,输入文件的所有字符的ASCII码都在闭区间[32, 126]内。且行尾没有空格。
Output

依次对应输入文件中每条GET指令的输出,不得有任何多余的字符。
Sample Input
10

Insert 13

Balanced eert

Move 2

Delete 5

Next

Insert 7

editor

Move 0

Get

Move 11

Rotate 4

Get

Sample Output
B

t

HINT

对输入数据我们有如下假定: MOVE操作不超过50 000个,INSERT、DELETE和ROTATE操作作的总个数不超过6 000,GET操作不超过20 000个,PREV和NEXT操作的总个数不超过20 000。 所有INSERT插入的字符数之和不超过2M(1M=1 024*1 024)。 DELETE操作、ROTATE操作和GET操作执行时光标后必然有足够的字符。MOVE、PREV、NEXT操作不会把光标移动到非法位置。 输入文件没有错误。

解法:维护一个支持区间分离合并翻转删除的Splay。

//BZOJ 1269 Splay

#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000010;
#define key ch[ch[rt][1]][0]
int pos=1, rt=0, tot=0, n, x, ch[maxn][2], siz[maxn], fa[maxn];
bool rev[maxn];
char v[maxn], op[10], input[maxn];
void newnode(int &k, char tt, int last)
{
    k = ++tot;
    fa[k] = last;
    v[k] = tt;
    ch[k][0]=ch[k][1]=rev[k]=0;
    siz[k]=1;
}
void pushup(int k)
{
    if(!k) return;
    siz[k] = siz[ch[k][0]]+siz[ch[k][1]]+1;
}
void update(int k)
{
    if(!k) return;
    rev[k]^=1;
    swap(ch[k][0],ch[k][1]);
}
void pushdown(int k)
{
    if(!k) return;
    if(rev[k])
    {
        update(ch[k][0]);
        update(ch[k][1]);
        rev[k]=0;
    }
}
inline void rotate(int x,int &k)
{
    int y=fa[x],z=fa[y],l=(ch[y][1]==x),r=l^1;
    pushdown(y), pushdown(x);
    if (y==k) k=x;
    else ch[z][ch[z][1]==y]=x;
    fa[x]=z;fa[y]=x;fa[ch[x][r]]=y;
    ch[y][l]=ch[x][r];ch[x][r]=y;
    pushup(y);pushup(x);
}
inline void splay(int x,int &k)
{
    while (x!=k)
    {
        int y=fa[x],z=fa[y];
        if (y!=k)
        {
            if ((ch[y][0]==x)^(ch[z][0]==y)) rotate(x,k);
            else rotate(y,k);
        }
        rotate(x,k);
    }
}
int findpos(int k, int rnk){
    pushdown(k);
    int l = ch[k][0], r = ch[k][1];
    if(siz[l]+1==rnk) return k;
    else if(siz[l] >= rnk) return findpos(l, rnk);
    else return findpos(r, rnk-siz[l]-1);
}
void split(int l, int r){
    int x = findpos(rt, l-1), y = findpos(rt, r+1);
    splay(x, rt);
    splay(y, ch[rt][1]);
}
void ins(int &k, int l, int r, int last){
    int mid = (l+r)/2;
    newnode(k, input[mid], last);
    if(l<mid) ins(ch[k][0],l,mid-1,k);
    if(mid<r) ins(ch[k][1],mid+1,r,k);
    pushup(k);
}
void workins(){
    scanf("%d%*c",&x);
    gets(input);
    split(pos+1,pos);
    ins(key,0,x-1,ch[rt][1]);
    pushup(ch[rt][1]);
    pushup(rt);
}
void workdel(){
    scanf("%d%*c", &x);
    split(pos+1,pos+x);
    fa[key]=0;key=0;
    pushup(ch[rt][1]);
    pushup(rt);
}
void workrev(){
    scanf("%d%*c", &x);
    split(pos+1,pos+x);
    update(key);
}
int main()
{
    newnode(rt,'*',0);
    newnode(ch[rt][1],'*',rt);
    pushup(rt);
    scanf("%d%*c", &n);
    for(int i=1; i<=n; i++){
        scanf("%s%*c", op);
        if(op[0]=='M'){
            scanf("%d%*c",&x);
            pos=x+1;
        }
        else if(op[0]=='I'){
            workins();
        }
        else if(op[0]=='D'){
            workdel();
        }
        else if(op[0]=='R'){
            workrev();
        }
        else if(op[0]=='G'){
            printf("%c\n", v[findpos(rt,pos+1)]);
        }
        else if(op[0]=='P'){
            pos--;
        }
        else pos++;
    }
    return 0;
}
伸展树的基本实现和区间操作 给定一个长度为N的序列,每个序列的长度是一个整数。要支持以下三种操作:  将[L,R]这个区间所有数加上V.  将[L,R]这个区间翻转,例如 1234变成 4321  求[L,R]区间的最大值 能力有限,实现可能有纰漏,也没有用到lazy_tag 立即下载

相关推荐

STM32C8T6HAL库实战:MAX30102心率血氧检测与OLED多级菜单一体化方案

本文详细介绍了基于STM32C8T6和HAL库的MAX30102心率血氧检测与OLED多级菜单一体化方案。内容涵盖硬件连接、CubeMX工程配置、传感器驱动移植、数据滤波算法、OLED显示驱动以及高效的多级菜单系统设计,旨在提供一个稳定、实用且易于移植的嵌入式健康监测项目参考。

weixin_29256771的博客 397

伸展树的查找、插入、删除

在信息处理中,刚被访问的数据,很有可能在短时间内被再次访问。在计算机系统中,同样如此。在总结点数为n的AVL树中,访问m次相邻数据共需要mlogn的时间。如果我们把经常访问的数据都放在树的顶端,那么时间就会减少很多。在此,我们引入了伸展树这一概念。 伸展树的概念 最基本的概念,逐层伸展:节点一旦被访问,就将其转移至树根。这一操作可以经过若干次单旋Zig或Zag操作来完成。自下而上,逐层单旋,直至v...

JTY541464341的博客 1681

文章详细介绍了进行DoIP(DiagnosticoverInternetProtocol)测试的完整过程,包括样件的正确接线、CANoe软件的环境配置、端口设置、VLAN配置、IP和MAC地址的设定

关于Tester和DUT的地址,其实最主要的就是DUT的IP、MAC和逻辑地址,如果不知道Tester的IP、MAC和逻辑地址,可以配置为与DUT同一网段的就可以。ps:最重的是知道DUT的IP、逻辑、MAC地址,如果有VLAN也需要知道,Tester的地址可以根据DUT地址进行设定,其余的值可根据DoIP的报文查到相关参数。ps:如果在通信中没有建立VLAN,但是源地址和目的地址都填写正确,此时就要考虑是否是遗漏了VLAN,建立一个VLAN,在重新试试是否可通信。此处与硬件连接是相对应的,要注意!

qq_40965861的博客 1128

hdu3487 (splay伸展树 区间翻转,切割,插入)

#include #include #include #include #include #include #include #define N 300010 using namespace std; //hdu3487 (splay伸展树 区间翻转,切割,插入) int pre[N], key[N], ch[N][2], size[N], rev[N], root, tot,

u012432475的专栏 647

Delta-Sigma调制(DSM)技术

前言 数字信号处理和通信系统的性能很大程度上受到了模拟信号到数字信号转换接口——ADC的精度和分辨率的限制。而传统的线性脉冲编码调制(PCM)ADC受到了制造工艺的限制,无法达到很高的分辨率。但基于Delta-Sigma调制技术的ADC可以在现有工艺下实现高分辨率(大于16位),同时由于结构简单,所以易于实现。低成本高性能使得Delta-Sigma调制技术得到了广泛的应用。 Delta-Sigma型ADC的结构原理图如下图所示: 它最大的优势在于仅用1位ADC进行数据转换,同时其模拟电路部分结构简单不需要

阿星的博客 2万+

msf使用木马控制android手机

使用msfvenom生成木马控制手机

my_name_is_sy的博客 3522

伸展树的原理及实现源代码(有图文详解和C++实现代码)

伸展树的原理及实现源代码(有图文详解和C++实现代码) 伸展树(Splay Tree)是一种二叉搜索树,它能在O(log n)内完成插入、查找和删除操作。它由Daniel Sleator和Robert Tarjan创造。它的优势在于不需要记录用于平衡树的冗余信息。在伸展树上的一般操作都基于伸展操作。 为什么需要伸展树(Splay Tree) 各种二叉搜索树存在不足。比如:对于一个有n个节点的平衡二叉搜索树,虽然最坏情况下每次查找的时间复杂度不会超过O(logn),但是如果访

遨游网络huster的专栏 4507

spring boot 集成cas(一) 服务端搭建

简单点就是统一服务认证,多个系统一次登录。俗称单点登录。

慕孑晨的博客 1956

算法笔记——伸展树

伸展树

m0_67142204的博客 1435

FPGA新手必看:用USB转TTL实现串口通信的完整流程(附CH340G电路详解)

本文为FPGA新手提供了通过USB转TTL模块实现串口通信的完整实战指南。详细解析了CH340G电路设计要点、硬件连接方法,并分享了经过验证的Verilog代码框架,帮助读者快速掌握FPGA与PC通信的核心技术,解决电平匹配与波特率设置等常见问题。

cake8的博客 1049

(计算机组成原理)第二章数据的表示和运算-第二节:数字电路基础知识

本文介绍了计算机组成原理中的逻辑门电路、多路选择器和三态门。逻辑门电路包括基本逻辑运算(与、或、非)和复合逻辑运算(与非、或非、异或、同或),这些运算通过门电路实现,并满足分配律和结合律。多路选择器(MUX)用于从多个输入信号中选择一个输出,广泛应用于数据选择、资源共享和逻辑函数实现等场景。三态门则具有三种输出状态(高电平、低电平、高阻态),常用于总线控制和信号隔离。这些元件在数字电路设计和计算机系统中具有重要作用。

快乐江湖的博客 2474

[HNOI2012]永无乡——[splay合并]

【题目描述】 永无乡包含 n 座岛,编号从 1 到 n ,每座岛都有自己的独一无二的重要度,按照重要度可以将这 n 座岛排名,名次用 1 到 n 来表示。某些岛之间由巨大的桥连接,通过桥可以从一个岛到达另一个岛。如果从岛 a 出发经过若干座(含 0 座)桥可以 到达岛 b ,则称岛 a 和岛 b 是连通的。 现在有两种操作: B x y 表示在岛 x 与岛 y 之间修建一座新桥。 Q x k 表示...

sleepyNick 338

【ComfyUI】QwenImageEdit OOTD角色与姿态匹配换装

本文介绍了一个基于Qwen Edit OOTD 2.0的ComfyUI工作流,能够实现角色与姿态匹配的智能穿搭生成。该工作流通过整合模型推理、姿态识别、图像拼接和渲染等节点,完成从角色图、姿态图到成品穿搭图的完整生成流程。核心采用Qwen Image系列模型进行图像理解和编辑,配合ControlNet进行姿态引导。用户只需提供角色图和姿态参考图,系统即可自动完成姿态解析、语义编码、采样生成等步骤,输出与输入姿态一致的穿搭图像。该方案适用于虚拟角色展示、电商试穿等场景,能保持角色特征一致的同时灵活变换姿态,显

Mr数据杨 1585

伸展树(Splay)

伸展树(Splay) 伸展树的作用范围很广,在某些情况下甚至可以代替线段树,伸展树最突出的特点就是区间操作:区间翻转,区间插入,区间删除,与其他二叉搜索树相比它能使得总体时间效率得到平摊,使得总效率为O(mlog n),当操作涉及到以区间为单位的位置变动时,就会使用到伸展树

C_eeking的博客 1386

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

伸展树的实现与分析:伸展算法的实现,查找、插入、删除算法的实现 (C++)

伸展树(splay tree) 通常在任意数据结构的生命期内,不仅执行不同操作的概率往往极不均衡,而且各操作之间具有极强的相关性,并在整体上多呈现出极强的规律性。其中最为典型的,就是所谓的“数据局部性”(data locality),这包括两个方面的含义:           1)刚刚被访问过的节点,极有可能在不久之后再次被访问到           2)将被访问的下一节点,极有可能就处于不久...

amoscykl的博客 2785

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

[AHOI2006]Editor文本编辑器Splay Pascal

http://www.lydsy.com/JudgeOnline/problem.php?id=1269 1269: [AHOI2006]文本编辑器editorTime Limit: 10 Sec Memory Limit: 162 MBDescription这些日子,可可不和卡卡一起玩了,原来可可正废寝忘食的想做一个简单而高效的文本编辑器。你能帮助他吗?为了明确任务目标,可可...

weixin_30783913的博客 193

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

伸展树(区间加值,反转,循环移动,插入,删除区间,求区间最小值)poj3580

Language: Default SuperMemo Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 10056   Accepted: 3234 Case Time Limit: 2000MS Description Your frie

龙崎的专栏 830

Splay Tree(伸展树)

二叉查找树(BinarySearchTree)能够支持多种动态集合操作。因此,在信息学竞赛中,二叉排序树起着非常重要的作用,它可以被用来表示有序集合、建立索引或优先队列等。 作用于二叉查找树上的基本操作的时间是与树的高度成正比的。对一个含n各节点的完全二叉树,这些操作的最坏情况运行时间为O(logn)。但如果树是含n个节点的线性链,则这些操作的最坏情况运行时间为O(n)。而有些二叉查找树的

2万+

伸展树(Splay tree)图解与实现

个人技术博客:http://blog.ztgreat.cn 一、伸展树    本文介绍了二叉查找树的一种改进数据结构–伸展树(Splay Tree)。它的主要特点是不会保证树一直是平衡的,但各种操作的平摊时间复杂度是O(log n),因而,从平摊复杂度上看,二叉查找树也是一种平衡二叉树。另外,相比于其他树状数据结构(如红黑树,AVL树等),伸展树的空间要求与编程复杂度要小得多。 伸展树...

小张的专栏 4万+

伸展树(插入区间,修改区间,区间置数,区间反转,区间求和,连续最大和)BZOJ1500

1500: [NOI2005]维修数列 Time Limit: 10 Sec  Memory Limit: 64 MB Submit: 6678  Solved: 2018 [Submit][Status] Description Input 输入文件的第1行包含两个数N和M,N表示初始时数列中数的个数,M表示要进行的操作数目。第2行包含N个数字,描述初始时的数列。

龙崎的专栏 1513

伸展树的删除例程

摘要:对要访问的节点进行访问这样会把该节点退到根处,删除根后得到两个子树.如果访问TL的最大节点,则该树变成一个没有右儿子的树,将TR接在TL上即可.Position Delete(Position T,int X) { Position TL,TR; if (T == NULL) { puts("error : X does not exist in the

pyb的博客 1271

查找——图文翔解SplayTree(伸展树)

伸展树 伸展树(Splay Tree),也叫分裂树,是一种二叉排序树,它由Daniel Sleator和Robert Tarjan创造,后者对其进行了改进。 假设想要对一个二叉查找树执行一系列的查找操作。为了使整个查找时间更小,被查频率高的那些条目就应当经常处于靠近树根的位置。于是想到设计一个简单方法,在每次查找之后对树进行重构,把被查找的条目搬移到离树根近一些的地方。splaytre

菜鸟的自留地-mooyang 8922

Splay伸展树入门(单点操作,区间维护)附例题模板

Pps:终于学会了伸展树的区间操作,做一个完整的总结,总结一下自己的伸展树的单点操作和区间维护,顺便给未来的自己总结复习用。 splay是一种平衡树,【平均】操作复杂度O(nlogn)。首先平衡树先是一颗二叉搜索树,刚刚开始学的时候找题hash数字的题先测板子。。。 后来那题被学长改了数据不能用平衡树测了。。。一道二分数字的题。 二叉搜索树的功能是,插入一个数字,在O(...

aihuiju2691的博客 378

[AHOI2006]文本编辑器editor (Splay tree)

我感觉伸展树越来越模版了,没想到这么轻易的就过了。。。 把光标位置标记为pos MOVE:pos++或者pos-- INSERT:把光标旋转至根部,然后把光标后一个字母旋转至根的右子树,然后把insert的内容插入到root的右子树的左子树 ROTATE:把光标旋转至根部,然后把光标后一个字母旋转至根的右子树,然后把rev[root10]取反 GET:得到光标位置的后

青竹梦 1529

HDU 1890 Robotic Sort(Splay 区间翻转)

Robotic Sort Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3741    Accepted Submission(s): 1629 Problem Description Somewhere deep in

I good vegetable a! 1043
上一篇: BZOJ 1266: [AHOI2006]上学路线route Floyd算法,网络最小割
下一篇: BZOJ 1270: [BeijingWc2008]雷涛的小猫 傻逼DP
just_sort
博客等级 码龄11年 2357粉丝 1667原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值