[DP][CDQ分治] BZOJ 4553: [Tjoi2016&Heoi2016]序列

计算机考研复试面试常问问题 数据结构篇(下) 计算机考研复试面试常问问题 数据结构篇(下) 使用前需知(拒绝白嫖,如果对你有帮助,你只需点个赞就行): 注意:有人在闲鱼上盗卖我的资料,而且还有很多同学买了,请各位擦亮双眼,我是整理出来免费分享给大家的! 大家请多点赞和评论,这样后面的同学更容易百度到,不至于被人盗卖,我就不加水印影响大家使用了! 第一次整理,度不好控制,有不好的地方希望大家理解,后面可能会改进,造福今年之后的同学们! ... 阅读详情

SolutionSolution

设位置ii最大可变成ri,最小lili。
fifi为ii位置的答案。容易得到

fi=max{fj+1|j<i,rj≤ai,aj≤li}
把(rj,aj)(rj,aj)当作二位平面的一个点,((ai,li),(0,0))((ai,li),(0,0))看作一个矩形。
就是一个类似二维数点的问题。
直接CDQCDQ分治就好了。
O(nlog2n)O(nlog2⁡n)

#include <bits/stdc++.h>
#define show(x) cerr << #x << " = " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> Pairs;

const int N = 202020;

inline char get(void) {
    static char buf[100000], *S = buf, *T = buf;
    if (S == T) {
        T = (S = buf) + fread(buf, 1, 100000, stdin);
        if (S == T) return EOF;
    }
    return *S++;
}
template<typename T>
inline void read(T &x) {
    static char c; x = 0; int sgn = 0;
    for (c = get(); c < '0' || c > '9'; c = get()) if (c == '-') sgn = 1;
    for (; c >= '0' && c <= '9'; c = get()) x = x * 10 + c - '0';
    if (sgn) x = -x;
}

int n, m, q, x, y, clc;
int mx[N], vis[N];
int a[N], l[N], r[N];
int f[N];
struct cpp {
    int x, y, z, id, tp;
    cpp(int _x = 0, int _y = 0, int _z = 0, int i = 0, int t = 0):
        x(_x), y(_y), z(_z), id(i), tp(t) {}
    inline bool operator <(const cpp &b) const {
        return x < b.x;
    }
};
cpp b[N];

inline void update(int x, int a) {
    for (x; x <= m; x += x & -x)
        if (vis[x] != clc) {
            mx[x] = a; vis[x] = clc;
        } else mx[x] = max(mx[x], a);
}
inline int query(int x) {
    int mx = 0;
    for (; x; x -= x & -x)
        if (vis[x] == clc)
            mx = max(mx, ::mx[x]);
    return mx;
}
inline void divAndConq(int l, int r) {
    static cpp tmp[N];
    if (l == r) return;
    int mid = (l + r) >> 1;
    int s1 = l, s2 = mid + 1;
    for (int i = l; i <= r; i++)
        if (b[i].z <= mid) tmp[s1++] = b[i];
        else tmp[s2++] = b[i];
    for (int i = l; i <= r; i++) b[i] = tmp[i];
    divAndConq(l, mid);
    ++clc;
    int j = l;
    for (int i = mid + 1; i <= r; i++) {
        for (; j <= mid && b[j].x <= b[i].x; j++)
            if (b[j].tp == 0)
                update(b[j].y, f[b[j].id]);
        if (b[i].tp == 1)
            f[b[i].id] = max(f[b[i].id], query(b[i].y) + 1);
    }
    divAndConq(mid + 1, r);
    int s = l; s1 = l; s2 = mid + 1;
    while (s1 <= mid && s2 <= r)
        if (b[s1] < b[s2]) tmp[s++] = b[s1++];
        else tmp[s++] = b[s2++];
    while (s1 <= mid) tmp[s++] = b[s1++];
    while (s2 <= r) tmp[s++] = b[s2++];
    for (int i = l; i <= r; i++) b[i] = tmp[i];
}

int main(void) {
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    read(n); read(q);
    for (int i = 1; i <= n; i++) {
        read(a[i]); f[i] = 1;
        l[i] = r[i] = a[i];
    }
    while (q--) {
        read(x); read(y);
        l[x] = min(l[x], y);
        r[x] = max(r[x], y);
    }
    for (int i = 1; i <= n; i++)
        m = max(r[i], m);
    q = 0;
    for (int i = 1; i <= n; i++) {
        b[++q] = cpp(a[i], l[i], q, i, 1);
        b[++q] = cpp(r[i], a[i], q, i, 0);
    }
    sort(b + 1, b + q + 1);
    divAndConq(1, q);
    cout << *max_element(f + 1, f + n + 1);
    return 0;
}
银行监管报送系统介绍(十五):金融审计平台 金审平台主要包括基础、财务、结算、信贷和中间业务五大板块,主要服务于审计署对中国银行的各项审计任务,同时也可为行内审计、稽核检查、数据分析、总分行提供基础数据服务,为实现基础数据共享提供了有力的数据保障。2019年1月某全国性股份制商业银行收到审计署2019-23号文,文中指出为进一步提高审计数据质量,审计署审计组派员前往9家重点商业银行,就完善标准化数据的相关情况与各银行有关部门进行讨论协商。关于数据报送频率及报送内容:数据从2019年4月开始,按月报送,即于每月25日之前报送上月数据; 阅读详情

相关推荐

auto.js梦幻西游游戏脚本,梦幻西游脚本开发思路

本篇文章给大家谈谈梦幻西游脚本用什么语言写,以及auto.js梦幻西游游戏脚本,希望对各位有所帮助,不要忘了收藏本站喔。

npy199331的博客 1939

BZOJ-4553:序列(cdq分治)

                                       4553: [Tjoi2016&amp;Heoi2016]序列                                                                 Time Limit: 20 Sec  Memory Limit: 128 MB                        ...

Mitsuha_的博客 525

Linux运维人,该醒醒了,2019年要变天了

外界都说运维只是处于被动低效率手工救火的状态,企业对其重视程度不高,提起运维很多人能联想到的字眼就有“苦逼”、“辛苦”、“加班”、“背锅”。在大数据、人工智能、容器技术的强力加持下,运维这个传统的技术工种已经从“机械劳动”这样的刻板印象中蜕变出来,成为了任何一家技术公司所必须依赖和大力投入的核心技术能力。 现在,运维人员的发展前景也开始让很多程序员眼羡,作为Linux运维人员的你:这一年,你的L...

qq_43083284的博客 1万+

LOJ#6289. 花朵 树链剖分+分治NTT

本来以为这道题会非常难调,但是没想到调了不到 5 分钟就 A 了. 由于基于多项式的运算都可以方便地进行封装,所以细节就不是很多(或者说几乎没有细节) 题意:给定一棵树,每个点有点权,求对于所有大小为 $m$ 的独立集的点权之积的和. 数据范围:$n,m \leqslant 8 \times 10^4$. 先考虑一个十分显然的 $O(n^2)$ 暴力: 令 $f[...

EM LGH 567

MMORPG网络游戏开发之任务系统的架构与设计

在网路游戏中做任务已经成为游戏很重要的一个核心功能和玩法,如何做好一个灵活可扩展的任务系统的架构与设计,今天来给大家分享一些我们的设计经验。接下来我把整个的任务系统分成以下6个模块:对于单机游戏而言,这6个模块都放在客户端直接处理,对于网路游戏而言,模块1~5实现在服务端,模块6实现在客户端。对啦!这里有个游戏开发交流小组里面聚集了一帮热爱学习unity的零基础小白,也有一些正在从事unity开发的技术大佬,欢迎你来交流学习。...

voidinit的专栏 3049

RS422总线

①.RS422发送驱动器无高阻三态(浮空)状态RS422收发芯片,发送脚固定强驱动输出,永远钳位 A/B 差分电平,不能关断、不能悬空,只要芯片上电,TX+、TX - 就强制输出互补电压(一路高、一路低)。多条发送并联在同一组差分线上:两个驱动器一个拉 A 高、一个拉 A 低,B 线反向拉扯 → 电源→地大电流对灌,瞬间芯片过流发烫烧毁、总线电平短路错乱。注意:RS485 带DE/RE 收发使能脚:不用发送时可关闭驱动器,输出变成高阻浮空,让出总线,因此能多节点分时发送。③.多点通信方式,一主多从方式;

zhuimeng_1234的博客 222

【LOJ6289】花朵(树上背包)(NTT)(链分治)(带权二分)

传送门 题解: 老年选手搞了半个月的文化课开始康复训练。 很显然要求的就是个独立集形式的树上背包。 写成卷积的形式链分治+带权二分即可。 很好写,拿下LOJ rk1。 复杂度 O(nlog⁡2n)O(n\log^2n)O(nlog2n),分析方式类似全局平衡二叉树。 看了下AC代码,除了我和rk2,剩下的分治部分似乎都是普通二分而不是带权二分,可以卡到 O(nlog⁡3n)O(n\log^3 n...

zxyoi_dreamer的博客(不定期诈尸) 1215

OV5640调试大坑,关于binning、RES分辨率与EV曝光

OV5640在使用binning模式时,必须考虑使用场景,分辨率下降叠加动态范围压缩,会使目标对象细节在高光环境下大量丢失,2x2的binning模式,分辨率会远低于感光面积的1/4。

chongyun_的专栏 1824

[ DP CDQ分治 ] BZOJ4553

设 li" role="presentation" style="position: relative;">lilil_i 表示 ai" role="presentation" style="position: relative;">aiaia_i 可以变成的最小值, ri" role="presentation" style="position: relative;">ririr_i 表示最大值

gjghfd 352

从HAL库SPI状态机机制剖析:为什么你的DMA发送会卡在BUSY状态?

本文深入剖析了STM32 HAL库中SPI状态机机制导致DMA发送卡在BUSY状态的常见问题。通过分析状态机设计原理,揭示了混合使用阻塞方式和DMA方式时状态切换冲突的根源,并提供了三种实战解决方案:正确配置SPI中断、使用HAL_SPI_Abort()函数以及手动管理状态机,帮助开发者实现稳定流畅的SPI DMA通信。

bush的博客 268

微信小程序 - 最新将页面可分享到朋友圈功能,小程序实现分享到朋友圈功能,开启分享给好友及分享朋友圈功能(微信小程序怎么分享到朋友圈?详细流程及示例代码教程)

没有设置过分享朋友圈功能的小程序,分享朋友圈按钮是灰色且无法点击。小程序 vue2 | vue3 版本语法都能使用,跟着教程复制代码运行即可。如下图所示,将页面开启分享后便可由用户转发出去。

🏆 前端领域优质创作者 2417

[bzoj4553][TJOI&HEOI2016]序列

题目大意有一个长度为n的序列,有一些位置的值有可能变化。 一次变化最多只会改变一个位置上的值,题目告诉了你可能发生的变化情况。 求在任意可能情况下都能满足非降的最长子序列长度。DP先弄出偏序关系,设mi[i]表示位置i可能出现的最小值,mx[i]就是最大值。 那么对于j<ij<i,j与i可以在一个合法子序列中的条件是: 1、a[j]<=mi[i] 2、mx[j]<=a[i] 设f[i]表

不来也不去的一只失忆蝴蝶 1707

CloudCompare 二次开发:插件中的 PCL 环境配置与编程

在进行 CloudCompare 的二次开发过程中,我们常常需要使用点云库(Point Cloud Library,简称 PCL)来处理和分析点云数据。在 CloudCompare 的界面中,选中一个点云对象,然后点击菜单栏中的 “插件” -> “MyPluginAction”。插件将对选中的点云对象进行体素滤波处理,并更新显示结果。下面我们将展示一个简单的插件编程示例,该示例使用 PCL 对输入的点云数据进行体素滤波处理。方法进行体素滤波处理,并将结果点云赋值给选中的点云对象。文件并点击 “打开”。

2301_79331387的博客 283

[BZOJ4553][Tjoi2016&Heoi2016]序列(CDQ 分治优化 DP)

Address https://www.lydsy.com/JudgeOnline/problem.php?id=4553 Solution 下面设三个值: aiaia_i :原序列 iii 位置的值。 aminiaminiamin_i : iii 位置可能被变换成的最小数值。 amaxiamaxiamax_i : iii 位置可能被变换成的最大数值。 而一个合法的子序列必须满足,对...

女装的你,如此好看! 374

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

bzoj4553 [Tjoi2016&Heoi2016]序列(CDQ分治+dp)

题目链接 分析: 发现这道题有点别扭哎 每次每刻只有一个数字发生变化(下一时刻变化取消) 每个位置都有一个变化范围 求一个子序列,使得在任意一种变化中,这个子序列都是不降的 换句话说,对于这个子序列中的一个位置,不管这个数怎么变化,ta的前驱都会小于等于ta,后继都会大于等于ta 记录每个点的变化范围(min[i],max[i])(min[i],max[i])(min[i],max[...

Coco_T的博客 409

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

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

bzoj 4553: [Tjoi2016&Heoi2016]序列 (CDQ分治+DP+树状数组)

题目描述传送门题目大意:有一个长为n的序列,m个变换,每次变换把x位置的权值变成v.求一个子序列满足在任意变换中都单调不降(任意变换不能同时进行),问子序列的最长长度。题解先考虑暴力DP。如果点j 可以用来更新i的答案。那么所有包含j的变换以及j初值的最大值一定小于等于i的初值。所有包含i的变换以及i的初值的最小值一定大于等于j的初值。也就是max[j]<=a[i],a[j]<=min[i],j<=

clover_hxy的博客 504

[bzoj4553][Tjoi2016&Heoi2016]序列 cdq分治

我不能说我不珍重这些荣誉,并且我承认它很有价值,不过我却从来不曾为追求这些荣誉而工作。

Unlimited Code Works 403

bzoj4553【TJOI2016&HEOI2016】序列

DP+CDQ分治

AaronPolaris 2212

BZOJ 4553: [Tjoi2016&Heoi2016]序列 CDQ分治 树套树

title BZOJ 4553 LUOGU 4093 Description 佳媛姐姐过生日的时候,她的小伙伴从某宝上买了一个有趣的玩具送给他。玩具上有一个数列,数列中某些项的值可能会变化,但同一个时刻最多只有一个值发生变化。现在佳媛姐姐已经研究出了所有变化的可能性,她想请教你,能否选出一个子序列,使得在任意一种变化中,这个子序列都是不降的?请你告诉她这个子序列的最长长度即可。 注意:...

dilu0653的博客 193

BZOJ4553: [Tjoi2016&Heoi2016]序列【CDQ+DP】

4553: [Tjoi2016&Heoi2016]序列 我们可以得出递推式dp[i]=dp[j]+1,j&lt;i,a[j]&lt;=L[i],R[j]&lt;=a[i]dp[i]=dp[j]+1,j&lt;i,a[j]&lt;=L[i],R[j]&lt;=a[i]dp[i]=dp[j]+1,j<i,a[j]<=L[i],R[j]...

XSamsara的博客 AFO 182

cdq分治——bzoj4553: [Tjoi2016&Heoi2016]序列

http://www.lydsy.com/JudgeOnline/problem.php?id=4553 先递归处理[l,mid] 对于所有在[l,mid]中的修改操作,处理它对于所有在[mid+1,r]中的询问操作的影响 再递归处理[mid+1,r] 这个就是cdq; 题意就是对于i>j max[j]<=a[i] a[j]<=min[i] 我们二分区间; 对于区间l~r

我怎么这么菜的呢 470

bzoj4553 [Tjoi2016&Heoi2016]序列

http://www.elijahqi.win/archives/2949 Description 佳媛姐姐过生日的时候,她的小伙伴从某宝上买了一个有趣的玩具送给他。玩具上有一个数列,数列中某些项的值 可能会变化,但同一个时刻最多只有一个值发生变化。现在佳媛姐姐已经研究出了所有变化的可能性,她想请教你 ,能否选出一个子序列,使得在任意一种变化中,这个子序列都是不降的?请你告诉她这个子序列...

Elijahqi 288

Bzoj4553: Tjoi2016&Heoi2016-序列

bzoj4553

tswdfop的博客 294

BZOJ4553 [Tjoi2016&Heoi2016]序列

设一个数的原值为v[i],最小能变化的值为l[i],最大值为r[i],观察一下可发现,i可放在j后面当且仅当r[j] 然而我写了一发树套树T了,今天模拟,考了一道题,也是dp最长某某某条件子序列转化为矩形最大值和加点,我又怒写一发树套树,结果又T了,xuruifan怒写KDT,T了,commonc怒写CDQ分治,过掉了-_- 然后当个双倍经验,我就写了这个CDQ分治 复杂度O(n log^2

neither_nor 1273

CDQ分治——BZOJ4553 [Tjoi2016&Heoi2016]序列

传送门 和带三维的关键字最长不降挺像 所以我们可以先搞出所有数的原值,最小值和最大值 然后可以CDQ求解 我们首先l~mid按照最大值排序,mid+1~r按照原值排序(每个排列最多只能改动一个数) 然后计算前面的对后面答案的影响即可 跟LIS差不多,只不过最后一维我们用一个树状数组来维护 最后清空一下(和二维矩阵差不多) 对就是这样,答案记录一下最大值就好了 然后关于树状数组和排序

2333:jzqjzq的博客专栏 565
上一篇: [后缀数组][trie合并][启发式合并][并查集] LOJ #6198. 谢特
下一篇: [NTT][DP][树链剖分][分治] LOJ #6289. 花朵
Vectorxj
博客等级 码龄11年 35粉丝 231原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值