BZOJ2002 洛谷3203 HNOI2010 弹飞绵羊LCT

Bioinformatics2021 | FraGAT+:基于分子原始片段的多尺度图注意力机制的分子性质预测模型 Bioinformatics2021 | FraGAT:基于分子原始片段的多尺度图注意力机制的分子性质预测模型 阅读详情

题目描述

某天,Lostmonkey发明了一种超级弹力装置,为了在他的绵羊朋友面前显摆,他邀请小绵羊一起玩个游戏。游戏一开始,Lostmonkey在地上沿着一条直线摆上n个装置,每个装置设定初始弹力系数ki,当绵羊达到第i个装置时,它会往后弹ki步,达到第i+ki个装置,若不存在第i+ki个装置,则绵羊被弹飞。绵羊想知道当它从第i个装置起步时,被弹几次后会被弹飞。为了使得游戏更有趣,Lostmonkey可以修改某个弹力装置的弹力系数,任何时候弹力系数均为正整数。

题解:
LCT。我们把每个点向它跳到的点连边,如果超过了n,就不连了,修改的话可以写link和cut,但是我写了一种许多原本LCT需要的函数都没写的写法,这个的link和cut可以直接改。
讲解一下核心代码吧。
核心代码是access(x);splay(x);
这个东西就是你把x到根的路径连通,之后再把x旋转到根,这样原来x与儿子连的边变成了轻边,不会被统计,所有原来比x深度小的点都到了x的左子树中,而此时x所在的子树大小就是步数。
代码如下:
#include <bits/stdc++.h>
using namespace std;

int n,m,a,s[200001],f[200001],c[200001][2],rev[200001];
int nroot(int x)
{
    return c[f[x]][0]==x||c[f[x]][1]==x;
}
void pushup(int x)
{
    s[x]=s[c[x][1]]+s[c[x][0]]+1;
}
void rotate(int x)
{
    int y=f[x],z=f[y],k=c[y][1]==x,w=c[x][!k];
    if(nroot(y))
    c[z][c[z][1]==y]=x;
    c[x][!k]=y;
    c[y][k]=w;
    if(w)
    f[w]=y;
    f[x]=z;
    f[y]=x;
    pushup(y);
}
void splay(int x)
{
    int y,z;
    while(nroot(x))
    {
        y=f[x];
        z=f[y];
        if(nroot(y))
        {
            if(c[y][0]==x ^ c[z][0]==y)
            rotate(y);
            else
            rotate(x);
        }
        rotate(x);
    }
    pushup(x);
}
void access(int x)
{
    int y=0;
    while(x!=0)
    {
        splay(x);
        c[x][1]=y;
        pushup(x);
        if(y!=0)
        f[y]=x;
        y=x;
        x=f[x];
    }
} 
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a);
        s[i]=1;
        if(a+i<=n)
        f[i]=a+i;
    }
    scanf("%d",&m);
    for(int i=1;i<=m;i++)
    {
        int x,y,z;
        scanf("%d",&x);
        if(x==1)
        {
            scanf("%d",&y);
            ++y;
            access(y);
            splay(y);
            printf("%d\n",s[y]);
        }
        if(x==2)
        {
            scanf("%d%d",&y,&z);
            ++y;
            access(y);
            splay(y);
            c[y][0]=f[c[y][0]]=0;
            if(y+z<=n)
            f[y]=y+z;
        }
    }
    return 0;
}

基于Simulink的轨道交通信号控制系统仿真详细介绍 轨道交通信号控制系统是确保列车安全、高效运行的核心技术。通过Simulink进行信号控制系统的仿真,可以验证系统的设计、优化调度策略并提高安全性。以下是如何在MATLAB和Simulink中设计并仿真一个轨道交通信号控制系统的详细步骤。通过上述步骤,我们成功设计并实现了基于Simulink的轨道交通信号控制系统仿真。该系统能够根据列车位置、速度和轨道状态生成控制指令,确保列车的安全、高效运行。通过虚拟场景仿真、硬件在环测试和实机测试,验证了系统的性能,并通过参数优化进一步提升了系统的可靠性。引入智能调度。 阅读详情

相关推荐

振动能量采集技术:从原理到实战,破解物联网供电难题

能量采集技术旨在捕获环境中的废弃能量(如机械振动、热能、光能)并将其转化为电能,其核心原理在于通过压电、电磁、静电或摩擦电等物理效应实现能量形式的转换。这项技术的核心价值在于为物联网(IoT)中难以布线或更换电池的分布式传感器节点、植入式医疗设备等提供近乎永续的电力解决方案,从而解决物联网部署的“最后一米供电”瓶颈。其应用场景广泛覆盖工业预测性维护、结构健康监测、可穿戴设备及消费电子等领域。本文聚焦于振动能量采集这一细分方向,深入剖析了压电式、电磁式、电容式及摩擦纳米发电机(TENG)等主流技术路线的实战考

weixin_42660494的博客 578

BZOJ 2002: [Hnoi2010]Bounce 弹飞绵羊 (动态树LCT)

2002: [Hnoi2010]Bounce 弹飞绵羊 Time Limit: 10 Sec  Memory Limit: 259 MBSubmit: 2843  Solved: 1519[Submit][Status] Description 某天,Lostmonkey发明了一种超级弹力装置,为了在他的绵羊朋友面前显摆,他邀请小绵羊一起玩个游戏。游戏一开始,Lostmonkey在地...

weixin_34417183的博客 310

RK3568(buildroot)利用squashfs+overlay实现嵌入式系统高可靠存储方案

本文详细介绍了在RK3568嵌入式平台上,基于Buildroot系统,利用squashfs只读根文件系统与overlayfs可写层相结合的高可靠存储方案。该方案能有效防止设备意外断电导致的系统文件损坏,通过内核配置、启动脚本编写及镜像制作,实现系统核心的只读保护与用户数据的持久化分离,显著提升嵌入式设备的现场稳定性。

weixin_29189381的博客 558

【HNOI 2010】Bounce 弹飞绵羊 分块

BZOJ Description 某天,Lostmonkey发明了一种超级弹力装置,为了在他的绵羊朋友面前显摆,他邀请小绵羊一起玩个游戏。游戏一开始,Lostmonkey在地上沿着一条直线摆上n个装置,每个装置设定初始弹力系数ki,当绵羊达到第i个装置时,它会往后弹ki步,达到第i+ki个装置,若不存在第i+ki个装置,则绵羊被弹飞。绵羊想知道当它从第i个装置起步时,被弹几次后会被弹飞。为了使得

Qantun_Mechanics的博客 1722

在Proteus中用80C51模拟4线SPI点亮OLED屏幕

在Proteus里用80C51模拟4线SPI控制OLED屏幕使其显示图案(汇编实现)。

Connor3093的博客 5017

深入Android构建系统:一次修改ro.vendor.build.fingerprint失败的排查与解决记录

本文深入探讨了Android构建系统中修改ro.vendor.build.fingerprint的完整解决方案。通过分析vendor分区的特殊地位和构建指纹的生成路径,提供了三种实战修改方法,并揭示了指纹修改可能遇到的陷阱与对策,帮助开发者彻底解决这一常见问题。

weixin_30621711的博客 161

[BZOJ]2002: [Hnoi2010]Bounce 弹飞绵羊 分块

Description 某天,Lostmonkey发明了一种超级弹力装置,为了在他的绵羊朋友面前显摆,他邀请小绵羊一起玩个游戏。游戏一开始,Lostmonkey在地上沿着一条直线摆上n个装置,每个装置设定初始弹力系数ki,当绵羊达到第i个装置时,它会往后弹ki步,达到第i+ki个装置,若不存在第i+ki个装置,则绵羊被弹飞。绵羊想知道当它从第i个装置起步时,被弹几次后会被弹飞。为了使得游戏更

TYB的博客 358

故障诊断 | 小波变换机械设备外圈振动信号故障诊断

故障诊断 | 小波变换机械设备外圈振动信号故障诊断

天天酷科研的博客 510

P3203 [HNOI2010]弹飞绵羊

题目链接 题目描述 某天,Lostmonkey 发明了一种超级弹力装置,为了在他的绵羊朋友面前显摆,他邀请小绵羊一起玩个游戏。 游戏一开始,Lostmonkey 在地上沿着一条直线摆上 nnn 个装置,每个装置设定初始弹力系数 kik_iki​,当绵羊达到第 iii 个装置时,它会往后弹 kik_iki​ 步,达到第 i+kii+k_ii+ki​ 个装置,若不存在第 i+kii+k_ii+ki​ 个装置,则绵羊被弹飞。 绵羊想知道当它从第 iii 个装置起步时,被弹几次后会被弹飞。为了使得游戏更有趣,Los

sky123博客 482

设备接入与APP(应用程序)接入华为云iotDA平台的详细操作步骤及获取方式

设备及APP(应用程序) 登录 IoTDA 平台所需的 入场与操作清单内容,提供逐项详细操作步骤和获取方式,并穿插贴士便于理解与实际操作落地。内容基于 华为云 IoTDA 控制台 和 IAM 控制台 的实际使用路径整理。

hy行者勇哥的博客 3088

【好玩的游戏项目】使用Docker快速部署属于你的RPG网页小游戏

【好玩的游戏项目】使用Docker快速部署属于你的RPG网页小游戏

jks212454的博客 5598

[清华集训2015]灯泡Zjoi3203 Light Bulbs

Compared to wildleopard's wealthiness, his brother mildleopard is rather poor. His house is narrow and he has only one light bulb in his house. Every night, he is wandering in his incommodious house, ...

lahlah的博客 1221

【Pix4d精品教程】Pix4d中央子午线细化设置(测区跨两个分带)

本文介绍了在Pix4d软件中通过修改中央子午线设置来解决跨分带测区刺点问题的方法。针对测区跨3度分带(如105°和108°之间)时像控点与靶标点偏移较大的情况,建议将中央子午线设为测区中心(如106.5°)。具体操作步骤包括:修改投影文件中的中央子午线参数,选择新的输出坐标系配置文件。该方法能有效提高像控点刺点效率,为航测内业数据处理提供便利。操作简单实用,适合大比例尺测图项目中跨分带测区的数据处理需求。

智慧空间实验室 5534

[BZOJ2002][洛谷P3203][Hnoi2010]Bounce 弹飞绵羊(LCT维护链长)

luogu传送门 2002: [Hnoi2010]Bounce 弹飞绵羊 Time Limit:10 SecMemory Limit:259 MBSubmit:16082Solved:8241[Submit][Status][Discuss] Description 某天,Lostmonkey发明了一种超级弹力装置,为了在他的绵羊朋友面前显摆,他邀请小绵羊一起玩个游...

weixin_30340617的博客 135

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

深度学习工具包 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")

题解 洛谷P3203/BZOJ2002【[HNOI2010]弹飞绵羊】

裸的LCT,关键是要怎么连边,怎么将这种弹飞关系转化成连边就行了。 那么我们可以这样连边: 一个节点i的爸爸就是i+ki。 没有i+ki那么就被弹飞了,即\(i\)的爸爸是虚拟节点n+1。 那么怎么求次数呢? i的深度就是次数 对于求深度,我们可以先将x弄成root,然后通过Access(n+1)将n+1号节点和x节点丢到一个Splay里面,维护一个size,每次询问的answer就是已经...

weixin_30652879的博客 70

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

洛谷 P3203 BZOJ 2002 [Hnoi2010]Bounce 弹飞绵羊

题目描述 某天,Lostmonkey发明了一种超级弹力装置,为了在他的绵羊朋友面前显摆,他邀请小绵羊一起玩个游戏。游戏一开始,Lostmonkey在地上沿着一条直线摆上n个装置,每个装置设定初始弹力系数ki,当绵羊达到第i个装置时,它会往后弹ki步,达到第i+ki个装置,若不存在第i+ki个装置,则绵羊被弹飞。绵羊想知道当它从第i个装置起步时,被弹几次后会被弹飞。为了使得游戏更有趣,Lostmo...

weixin_30260399的博客 136

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

BZOJ2002: [Hnoi2010]Bounce 弹飞绵羊(洛谷P3203)

LCT BZOJ题目传送门 洛谷题目传送门 新增一个点n+1表示弹飞的点。 刚开始把i和i+ki接起来,查询时直接把x到n+1的路径拎出来,答案就是节点个数-1。改值时把x和x+ki断开,再把x和x+y接起来。注意对n+1取min。 代码: #include #include #include #include #define N 200005 #define il inline #d

forezxl的博客 347

[HNOI2010]BOUNCE 弹飞绵羊

题目:BZOJ2002、洛谷P3203、codevs2333。 题目大意:有n个装置,编号0~n-1。每个装置有一个弹跳系数,第i个装置可以把羊弹到第$i+k_i$个装置上,然后继续弹。如果这个位置没有装置,则停止弹。 现在有m个操作,可以问你一只绵羊在某点开始弹,弹多少次才能结束,也可以修改一个装置的弹跳系数。 解题思路:分块。 一般都是每块分成$\sqrt{n}$个(最后一个...

103

2018.10.08【HNOI2010】【BZOJ2002】【洛谷P3203】弹飞绵羊(LCT)

BZOJ传送门 洛谷传送门 解析: LCTLCTLCT裸题啊。。。 思路: 可以很显然的发现不管怎么变,我们设置虚拟节点n+1n+1n+1,所有点到它的路径构成一棵树。 那不就完了,直接LCTLCTLCT维护这棵路径树的形态,路径上经过多少点就是要被弹多少次,在LCTLCTLCT的节点里维护sizsizsiz,最后提取路径,siz−1si...

anlongyi8087的博客 116

BZOJ2002 [HNOI2010]Bounce 弹飞绵羊

Address 洛谷P3203 BZOJ2002 Solution LCT" role="presentation" style="position: relative;">LCTLCTLCT 模板题…… 因为原图无环,把位置看做 n" role="presentation" style="position: relative;">nnn 个点,用 LCT" role="prese

Log_x's Blog 368

BZOJ2002:[HNOI2010]弹飞绵羊——题解

http://www.lydsy.com/JudgeOnline/problem.php?id=2002 https://www.luogu.org/problemnew/show/P3203 某天,Lostmonkey发明了一种超级弹力装置,为了在他的绵羊朋友面前显摆,他邀请小绵羊一起玩个游戏。游戏一开始,Lostmonkey在地上沿着一条直线摆上n个装置,每个装置设定初始弹力系数ki,...

weixin_34107739的博客 109

初识lct——洛谷p3203 bzoj2002 [HNOI2010]BOUNCE 弹飞绵羊

题目大意:现在有n个装置,每个装置会弹到一个地方(编号一定在它之后),也可能直接弹了出去,动态修改会弹到的地方,和动态查询从一个装置出发多少次会被弹出去。

Cold_Chair的博客 637

洛谷P3203/bzoj2002 [Hnoi2010]Bounce 弹飞绵羊

题目链接 据说是一道LCT模板题 然而我并不会LCT,所以用分块做法切了他 维护每个点跳出当前块所需次数,及跳到下个块的什么位置就好了 #include #include #include #include #define For(i,j,k) for(int i=j;i<=k;i++) #define Forr(i,j,k) for(int i=j;i>=k;i--) using n

zybnnhz的博客 303

[HNOI 2010] 弹飞绵羊

题目描述: 有N个装置 每个装置有一个参数K 在i装置上可以到i+k位置 问几次可以弹飞出去 题目要求 要资瓷修改和查询操作 如果没修改用dfs即可 修改可咋办QWQ 我们考虑用LCT来维护这些点的连接关系 当i+k&gt;n时 fa[i+k]=n+1 这样每次查询的时候即为查询X点到n+1的距离 这样我们每次让 n+1 makeroot 然后让access(x) s...

HT008的Blog 304
上一篇: NOI2014 洛谷2387 bzoj3669 魔法森林 LCT
下一篇: WC2006水管局长 洛谷4172 bzoj2594 LCT
forever_shi
博客等级 码龄9年 75粉丝 280原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值