CodeForces - 558E.A Simple Task(线段树-区间重排)

基于YOLOv12的牙齿识别与计数系统:从理论到完整实现 本文详细介绍了一种基于YOLOv12深度学习模型的牙齿识别与计数系统。该系统能够在口腔X光片中准确识别和计数牙齿,并提供了用户友好的UI界面。文章涵盖了数据预处理、模型训练、性能优化以及完整系统实现的各个环节,并提供了可复现的代码和数据集参考。整个系统包含三个主要模块:数据预处理模块YOLOv12模型训练模块UI界面展示模块。 阅读详情

题目

给你一个长度为n(n<=1e5)的字符串,

和q(q<=5e4)次修改操作,

每次修改输入i,j,k三个数,

k==1,表示对[i,j]区间按字典序不降序排序

k==0,表示对[i,j]区间按字典序不增序排序

要求输出修改之后的字符串

思路来源

归神の例会

题解

开26棵线段树,重排时,

只需先类似计数排序统计出[i,j]段每个字母出现的个数,

再根据k的值选择增序或降序,

对每棵线段树内对应的区间位置先清零后在对应位置赋1即可

查询时,每个位置单点查询有没有字母,查到就break

心得

其实还是区间赋值啦,板子改一改就能AC了

只是要注意几个细节,比如输入字符串的下标,num[j]==0时直接跳过等等

只是自己写的最后询问答案时候,变成了26棵树一一logn询问,总感觉有点不妥……

所幸复杂度没超,总复杂度O(26*(n+q)*logn)

代码

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
//基数排序思想 统计出来每个区间对应'a'到'z'各多少个字母
//'a'-'z'每个字母开一棵线段树用于区间赋值 
char s[maxn];
int num[26];
int pos;//下一字母的起始位置 
int dat[26][maxn*5],cov[26][maxn*5];
int n,q;
int l,r,op;
void pushup(int a[],int b[],int p)
{
	a[p]=a[p<<1]+a[p<<1|1];
	if((~b[p<<1])&&(~b[p<<1|1]))b[p]=-1;
}
void build(int p,int l,int r)
{
	for(int i=0;i<26;++i)
	cov[i][p]=-1;//-1表示没有操作,与区间赋0区别 
	if(l==r)
	{
		for(int i=0;i<26;++i)
		{
			if(i==s[l]-'a')dat[i][p]=1;
			else dat[i][p]=0;
		}
		return;
	}
	int mid=(l+r)/2;
	build(p<<1,l,mid);
	build(p<<1|1,mid+1,r);
	for(int i=0;i<26;++i)
	pushup(dat[i],cov[i],p);
}
void pushdown(int a[],int b[],int p,int l,int r)
{
	if(~b[p])
	{
		int mid=(l+r)/2;
		a[p<<1]=b[p]*(mid-l+1);
		a[p<<1|1]=b[p]*(r-mid);
		b[p<<1]=b[p];
		b[p<<1|1]=b[p];
		b[p]=-1;
	}
}
void update(int a[],int b[],int p,int l,int r,int ql,int qr,int v)//区间赋1或赋0 
{
	if(ql<=l&&r<=qr)
	{
		a[p]=v*(r-l+1);
		b[p]=v;
		return;
	}
	pushdown(a,b,p,l,r); 
	int mid=(l+r)/2;
	if(ql<=mid)update(a,b,p<<1,l,mid,ql,qr,v);
	if(qr>mid)update(a,b,p<<1|1,mid+1,r,ql,qr,v);
	pushup(a,b,p);
}
int ask(int a[],int b[],int p,int l,int r,int ql,int qr)
{
	if(ql<=l&&r<=qr)return a[p];
	pushdown(a,b,p,l,r);
	int mid=(l+r)/2,ans=0;
	if(ql<=mid)ans+=ask(a,b,p<<1,l,mid,ql,qr);
	if(qr>mid)ans+=ask(a,b,p<<1|1,mid+1,r,ql,qr);
	return ans; 
}
int main()
{
	scanf("%d%d",&n,&q);
	scanf("%s",s+1);//细节1:[1,n]  
	build(1,1,n);
	for(int i=1;i<=q;++i)
	{
		scanf("%d%d%d",&l,&r,&op);
		pos=l;
		//细节2:清零会被赋值覆盖 故不用清零 
		for(int j=0;j<26;++j)
		{
		 num[j]=ask(dat[j],cov[j],1,1,n,l,r); 
		 update(dat[j],cov[j],1,1,n,l,r,0);
	    }
	    if(op==1)
	    {
	    	for(int j=0;j<26;++j)
	    	{
	    		if(!num[j])continue;//细节3 
	    		update(dat[j],cov[j],1,1,n,pos,pos+num[j]-1,1);//pos+num[j]-1>=pos 要求num[j]>=1 
	    		pos=pos+num[j];
	    	}
	    }
	    else 
	    {
	    	for(int j=25;j>=0;--j)
	    	{
	    		if(!num[j])continue;
	    		update(dat[j],cov[j],1,1,n,pos,pos+num[j]-1,1);
	    		pos=pos+num[j];
	    	}
	    }
	}
	for(int i=1;i<=n;++i)
	{
		for(int j=0;j<26;++j)
		{
			if(ask(dat[j],cov[j],1,1,n,i,i)>0)
			{
				putchar(j+'a');
				break;
			}
		}
	}
	puts("");
	return 0;
} 

 

基于simulink的预测电流控制策略的三相逆变器仿真 本文详细介绍了在Simulink中实现基于预测电流控制策略的三相逆变器仿真方法。主要内容包括:准备工作(安装必要软件及工具箱)、构建三相逆变器基础模型、设计预测电流控制器(包含状态空间建模和控制器设计)、实现控制逻辑、添加示波器观察输出、配置仿真参数以及运行仿真分析结果。通过MATLAB代码示例和Simulink模块说明,展示了如何选择最优开关状态来最小化电流误差。该仿真方法为研究快速响应、高精度的逆变器控制提供了实用工具,但需注意实际应用中可能需要的调试工作。 阅读详情

相关推荐

STM32F103移植NuttX实战:从零搭建最小系统到串口Shell(附完整配置文件)

本文详细介绍了在STM32F103C8T6开发板上移植NuttX实时操作系统的完整过程,包括环境搭建、BSP配置、系统时钟初始化、驱动裁剪、编译烧录及串口Shell交互。通过实战指南帮助开发者快速掌握NuttX移植技巧,解决典型问题,适用于嵌入式系统开发。

tree8的博客 297

Codeforces 558(C、D、E)总结

Codeforces 558(C、D、E)总结 —— black的专栏 —— waShaXiu

black的专栏 1403

三款云电脑实测:ToDesk、青椒云、顺网云谁更适合AIGC新手?附详细配置对比

本文针对AIGC新手,深度实测了ToDesk云电脑、青椒云和顺网云三款云电脑服务。通过对比上手门槛、内置生态、操作引导及成本,发现ToDesk云电脑凭借一键启动、丰富预置模型和直观引导,为新手提供了最接近“开箱即用”的零门槛AIGC创作体验,是快速入门AI绘画的高效选择。

assembly8low的博客 1099

Codeforces 558E - A Simple Task

A Simple Task 题目链接 我们可以用区间覆盖的想法去解决这个问题。我们可以开 262626 颗线段树,去维护某个字母的区间覆盖。那么我们只要按照升序或者降序去遍历每个字母,首先求出某个字母在 [L,R][L,R][L,R] 的个数 cntcntcnt ,然后把原先的 [L,R][L,R][L,R] 都覆盖为 000 ,因为已经放好前面的字母,所以也应该得知当前字母覆盖的起始位置 pospospos ,那么我们将这个字母的 [pos,pos+cnt−1][pos,pos+cnt-1][pos.

qq_45863710的博客 328

大模型抽取知识图谱三元组的可行性分析

通过结合传统信息抽取模型与大语言模型的混合架构,可高效完成从学术文献到知识图谱三元组的全流程构建。分阶段优化:传统模型负责粗粒度抽取,大模型负责细粒度修正。灵活提示设计:通过少样本学习引导大模型理解领域本体。严格质量控制:结合规则引擎和人工校验,确保三元组准确性。该方案可显著提升知识图谱构建效率,适用于学术研究、企业知识库等场景。

qq_20647053的博客 1067

Arduino程序设计(十)8×8 共阴极LED点阵显示(MAX7219)

本文主要介绍8×8 LED点阵显示实验,分别是:1、介绍MAX7219点阵模块;2、点阵显示部分图形;3、点阵显示数字 0~9 及 26 个英文字母。1、通过上述两个点阵实验,了解了8*8点阵显示的基本原理;2、通过SPI通信控制点阵显示,学会了Arduino用SPI通信方式控制外设。

Alice的博客 1万+

Codeforces 558E A Simple Task (计数排序+线段树优化)

E. A Simple Task time limit per test 5 seconds memory limit per test 512 megabytes input standard input output standard output This task is very simple. Given a string S

quailty's 2101

Oracle EBS Interface/API(42) -AP发票客制化付款申请

背景 在OA系统上,选择Oracle EBS的某张AP发票做付款申请,需要类似于锁定该发票以便付款,其他用户或者下次用户不能再次选择该发票做付款申请。 快速参考 参考点 内容 功能导航 N: AP->Invoices->Entry>Invoices 并发请求 None 基表 AP.AP_INV_SELECTION_CRITERIA_ALLAP.AP_SELECTED_INVOICES_ALL API 参考下面介绍 错误信息表 None 接口Form

陈显平的专栏-Oracle EBS 1201

Codeforces 558E. A Simple Task (线段树+计数排序)

线段树+计数排序

岩之痕 3319

基于YOLOv8与UI界面的短视频内容审核系统实现与深度学习应用

YOLO(You Only Look Once)是一种用于实时物体检测的深度学习模型,它能在单次前向传播中同时完成物体检测和定位。YOLOv8是YOLO系列中的最新版本,相较于之前的版本,YOLOv8具有更高的检测精度和更快的推理速度,特别适合需要实时检测的应用场景。YOLOv8通过卷积神经网络(CNN)来提取图像中的特征,并通过多个卷积层来预测每个目标的位置和类别。该模型的优势在于其端到端的结构,使得在视频监控、自动驾驶、安防监控等实时应用中,能够实现快速且高效的目标检测。

YOLO 316

YOLOv4目标检测算法——通俗易懂的解析

YOLOv4目标检测算法——通俗易懂的解析

chase 7140

codeforces 558E E. A Simple Task( 线段树+统计排序)

题目连接:codeforces 558E题目大意:给出一个字母的序列(只包含小写字母),每次对它的一个区间进行排序,问最后的字母序列。题目分析:首先因为字母的数量很小,我们很容易想到统计统计排序这个O(26*log(n))的排序方法,对于每个要排序的区间,我们只需要从小到大统计每个字母有多少个,然后顺序输出即可,利用26棵线段树维护,可以做到O(logn)的复杂度。最后输出即可,总的复杂度O(26*

llin-黎辰 808

Superpowers与 OpenSpec、Spec Kit 对比

按照官方仓库定义,Superpowers 是一套构建在 composable skills 之上的完整软件开发工作流。它不是单纯的 prompt 集合,而是把一系列工程动作做成默认流程。一个需要明确的点:Superpowers 并不只偏 Claude Code,根据。

人不风流枉少年 1828

【30.93%】【codeforces 558E】A Simple Task

time limit per test5 seconds memory limit per test512 megabytes inputstandard input outputstandard output This task is very simple. Given a string S of length n and q queries each qu...

AWCXV 75

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

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

codeforces558e,好题

http://codeforces.com/problemset/problem/558/E E. A Simple Task time limit per test 5 seconds memory limit per test 512 megabytes input standard input output standard

郭大帅 1272

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

codeforces 558E

计数排序: 计数排序就是对于一个已知序列找出序列最大值,最小值后。开辟一个大小为max-min+1的辅助数组,在辅助数组上对已知序列进行计数。即fuzhu[a[i]-min]++。然后再在愿数列上按照一定顺序(降序/升序)进行赋值。 for(int i=0,j=0;i&lt;max-min+1;i++)//升序 { if(fuzhu[i]!=0) { a[j+...

Black__wing的博客 328

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

[线段树] codeforces 558E. A Simple Task

题意: 给一个长度n的字符串,q次操作,每次操作把[l,r]排序,k=0非递增,k=1非递减。 题解: 采用计数排序的复杂度是O(n∗q)O(n*q),无法通过,但有所启示。 可以看出计数就是区间求和,排序就是区间更新,可以用线段树维护。 做法是建立26棵线段树,第i棵树维护第i个字母的位置信息。 计数时,在26棵线段树内分别做一次查询,排序时根据递增还是递减,把相应的区间赋值为相应的字

穹妹的家 1248

Codeforces 558E A Simple Task (计数排序+线段树)

题解参考自大佬Black__wing 题目链接A Simple Task 题意:给定一个字符串(只由小写字母组成),每次进行两种操作,将区间[l,r]升序或者降序排序,求q次操作后字符串结果。 题解:我们可以利用计数排序思想(不懂也没关系,直接看下面),对每个字母建一颗线段树,维护每个字母在每个区间内出现次数,对于每次的操作,我们只需要先把[l,r]区间内每个字母出现次数先记录下来并清空其在该区间的出现次数,然后直接按字母大小从左往右依次填入区间(利用线段树将该字母对应区间都占满),这样就实现了区间.

m0_56280274的博客 325

Codeforces 558E A Simple Task (简单题)

题目类型 简单题 题目意思 对于一个最多 1e5 长的字符串(只包含小写字母) 有 50000 个操作 每个操作参数为 l, r, k (当k == 1时表示将子串 (l, r) 中的子符非降序排序 当 k == 0时非升序) 问 50000 个操作后得到的字符串是什么 解题方法 分析一下可以发现突破口在于字符串只包含小写字母,即

yunyouxi0's blog 1149

codeforces 558E. A Simple Task

codeforces 558E. A Simple Task 线段树 题目传送门 **题目大意:**给你一个字符串,每次对一个区间进行降序或升序排序,求最后的字符串。 开26棵线段树,每一棵维护一个字母的位置,直接模拟就好了。O(26qlog⁡n)O(26q\log n)O(26qlogn)稳得很。 还有一种做法是基于这道题的。每做一次就可以知道其他位置的相对大小关系,这样做26次就全都知道了。复...

forezxl的博客 321

codeforces 558 E A Simple Task

题目大意就是给一个字符串,然后多个操作,每次操作可以把每一段区间的字符进行升序或者降序排序,问最终的字符串是怎样的。 做法的话就是用线段树维护区间和   一开始只考虑字符串中字符'a'的情况,假设操作区间[L,R]中有x个'a',那么一次操作后,这x个'a'要么去最左(升序),要么去最右(降序),我们可以建立一颗线段树来维护这样的操作,字符'a'出现的位置值为1,否则为0,那么q次

Last Order 1154

Codeforces 558E 线段树处理字符串内排序

给出长度为n的字符串,m个操作。 每个操作有三个值 l,r,op。 op==1,表示将字符串中[ l ,r ]的部分按照升序排列。 op==0,表示将字符串中[ l ,r ]的部分按照降序排列。 输出最终的字符串 按小写字母建26颗线段树 对于每次修改,先记录[l,r]区间内各个字母出现的次数,并对相应区间清空,然后按照升序或者降序从新更新 #include "std

1199

[计数排序 线段树] Codeforces 558E #312 (Div. 2) E. A Simple Task

开26棵线段树 记录每个字符的情况 #include #include #include using namespace std; inline char nc(){ static char buf[100000],*p1=buf,*p2=buf; if (p1==p2) { p2=(p1=buf)+fread(buf,1,100000,stdin); if (p1==p2)

雯舞 286

Codeforces558E A Simple Task (线段树分裂 / 01线段树)

题目链接: A Simple Task 大致题意 给你一个长度为n个字符串, 有m次操作, 每次给定区间[l, r], 让你对这个区间升序 / 降序排列 最终输出m次排序后的序列. 解题思路 线段树分裂 or 01线段树 思路一: 线段树分裂, 复杂度: O((n + m)log26) 我看这个题并没有线段树分裂的做法, 但对于本题而言, 确实是一种非常优秀的解法. 且可以进行推广, 即对于n个数字进行区间排序. 这是01线段树做不到的. 核心思路: 对于每一个有序区间, 都开一棵权值线段树, 用set去维

Fau的博客 312

CodeForces - 558E A Simple Task (计数排序 线段树)

This task is very simple. Given a string S of length n and q queries each query is on the format i j k which means sort the substring consisting of the characters from i to j in non-decreasing order i...

henuzxy 546

CodeForces - 558E.A Simple Task字符串区间排序(计数排序+26棵线段树的维护)

题目链接http://codeforces.com/problemset/problem/558/E Time limit :5000 ms Memory limit : 524288 kB This task is very simple. Given a string S of length n and q queries each query is on the format i j k w...

孤风的博客 571
上一篇: CCPC-Wannafly Winter Camp Day5 Div2 I.Sorting(线段树-区间重排)
下一篇: Codeforces Round #556 (Div. 2) D - Three Religions(dp+string)
小衣同学
博客等级 码龄9年 1444粉丝 995原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小衣同学

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值
⌂ 换网址