HDU 1754 I Hate It (RMQ线段树)

驯服电源尖峰:从BUCK/BOOST环路剖析到高di/dt噪声的实战抑制 本文深入探讨了电源系统中高di/dt噪声的产生机制及抑制方法,通过BUCK/BOOST电路的环路分析,揭示了电流路径不连续导致的电压尖峰问题。文章提供了实用的PCB布局技巧和噪声抑制策略,包括最短回路原则、铺铜优化和过孔阵列战术,帮助工程师有效降低EMI噪声,提升电源系统的稳定性。 阅读详情

http://acm.hdu.edu.cn/showproblem.php?pid=1754


模板。


/*1062ms,2284KB*/

#include <cstdio>
#include <algorithm>
using namespace std;
#define lson l, m, rt << 1
#define rson m + 1, r, rt << 1 | 1
#define root 1, n, 1
const int mx = 200000;

int maxs[mx << 2];

inline void pushup(int rt)
{
	maxs[rt] = max(maxs[rt << 1], maxs[rt << 1 | 1]);
}

void build(int l, int r, int rt)
{
	if (l == r)
	{
		scanf("%d", &maxs[rt]);
		return;
	}
	int m = (l + r) >> 1;
	build(lson);
	build(rson);
	pushup(rt);
}

void update(int p, int s, int l, int r, int rt)
{
	if (l == r)
	{
		maxs[rt] = s;
		return;
	}
	int m = (l + r) >> 1;
	if (p <= m) update(p, s, lson);
	else update(p, s, rson);
	pushup(rt);
}

int query(int ql, int qr, int l, int r, int rt)
{
	if (ql <= l && r <= qr)
	{
		return maxs[rt];
	}
	int maxs = 0, m = (l + r) >> 1;
	if (ql <= m) maxs = query(ql, qr, lson);
	if (m < qr) maxs = max(maxs, query(ql, qr, rson));
	return maxs;
}

int main()
{
	int n, m, a, b;
	char c;
	while (~scanf("%d%d", &n, &m))
	{
		build(root);
		while (m--)
		{
			getchar();
			scanf("%c%d%d", &c, &a, &b);
			if (c == 'U') update(a, b, root);
			else printf("%d\n", query(a, b, root));
		}
	}
	return 0;
}

VS2022下OSG+OSGEARTH开发环境一键配置指南(Win10 x64+CMake自动化构建) 本文详细介绍了在VS2022环境下配置OSG和OSGEARTH开发环境的完整指南,包括软件下载、CMake自动化构建、编译实战及环境验证。通过一键配置脚本和常见问题解决方案,帮助开发者快速搭建3D开发环境,提升开发效率。 阅读详情

相关推荐

AXI DataMover实战:从FPGA逻辑到DDR的高效数据传输

本文深入解析了AXI DataMover在FPGA开发中的核心应用,作为连接FPGA逻辑与DDR内存的“金牌管家”,它能高效管理AXI-Stream与AXI4协议间的数据传输。文章详细拆解了其命令、数据流与内存映射三组核心接口,并通过实战配置与Verilog代码示例,指导开发者如何快速搭建系统、发送精准命令并进行性能调优,从而解放开发者,专注于核心逻辑设计。

weixin_29212429的博客 409

HDU 1754 I Hate It 线段树 RMQ

题意:给一串序列,有两种操作:更新某点x序列值为y;求区间[x, y]内序列最大值 思路:线段树模版题,建立线段树,节点值为该区间内最大值,更新时递归更新保证父亲节点在子节点更新后得到更新,查询时若查询区间完全包含当前区间,则返回当前区间值,否则返回两个子区间的最大值。在递归求子区间最大值时,需要判断当前区间是否与查询区间相交,只有相交时才继续递归。 #include<iostream&gt...

qq_42397248的博客 178

Qt·DBus快速入门

DBus快速入门

m0_64560763的博客 2281

HDU 1754 I Hate It 线段树 RMQ 支持修改数列的值

//http://acm.hdu.edu.cn/showproblem.php?pid=1754 //4671581 2011-09-28 14:15:02 Accepted 1754 265MS 6452K 2127 B G++ nkhelloworld //4671584 2011-09-28 14:15:21 Accepted 1754 218MS 6388K 2127 B...

146

用Multisim复刻经典收音机:从零搭建超外差中波调幅接收机(附仿真源文件)

本文详细介绍了如何使用Multisim软件从零搭建超外差中波调幅接收机,复刻经典收音机的设计过程。通过模块化搭建、稳定性优化和增益分配等实战指南,帮助读者掌握超外差架构的核心技术,并附赠仿真源文件供实践参考。

weixin_28744423的博客 490

Unity3D实战:用EasyAR4.0稀疏空间地图打造AR导航应用(附完整代码)

本文详细介绍了如何使用Unity3D和EasyAR4.0的SparseSpatialMap功能构建AR导航应用。通过稀疏空间地图技术,开发者可以创建室内导航系统,解决传统GPS在室内环境中的局限性。文章包含完整代码示例,涵盖环境配置、地图构建、导航实现及性能优化等关键步骤,助力开发者快速掌握AR导航开发技巧。

t8u9v0的博客 1212

hdu 1754 【线段树/RMQ】I Hate It

Problem Description 很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。 这让很多学生很反感。 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。   Input 本题目包含多组测试,请处理到文件结束。 在每个测试的第一行,有两个正整数 N

ACM_e的博客 399

Xilnx大学计划/XUP ZYNQ ZU开发板

TUL PYNQ™-ZU板,基于Xilinx Zynq UltraScale+ MPSoC,是为Xilinx大学项目设计的,以支持Xilinx PYNQ (Python Productivi-ty for Zynq)开源框架和嵌入式系统开发。

weixin_57025922的博客 960

【题解】I Hate It HDU - 1754 (线段树 RMQ 模板题)⭐⭐

I Hate It HDU - 1754 很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。 这让很多学生很反感。 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。 Input 本题目包含多组测试,请处理到文件结束。 在每个测试的第一行,有两个正整数 N 和 M ( 0<N<=...

Suprit's blog 1215

【局部规划模块曲线算法】曲线平滑介绍

本文先对轨迹平滑问题做个简单的介绍,具体内容后续再更,其他模块可以参考去我其他文章提示:以下是本篇文章正文内容(1)适合给移动机器人运动的路径【满足运动学,高阶平滑】(2)高阶的运动学不能够突变的【至少三阶的加速度不能突变,最好四阶的jerk和五阶的snap也不能突变】(3)在转弯的地方不会停下来(4)加减速均衡,节省能量(5)节省时间的。

qq_35635374的博客 5728

LOFIC / 全局快门在移动端的可行性:曝光容限、读出噪声与算力预算

手机端引入 LOFIC 与全局快门的核心权衡在于:在有限像素面积与功耗下,如何换取更高的动态范围与运动场景鲁棒性。LOFIC 通过侧向溢流到积分电容扩大满井并保持较高转换增益,全局快门在帧内一次性采样消除行时序伪影,但需付出像素填充率、读出噪声与片上存储功耗的代价。本文以工程可实操为目标,给出像素与读出链的简化模型、曝光损益测算、数据率与带宽估算、端到端算力与热预算方法,配套寄存器配置流程、帧内/帧间切换策略与验证清单,帮助在真实移动 SoC 与 ISP 约束下完成可行性评估与原型落地。

努力分享一些人工智能、计算机视觉、影像等相关的知识干货! 1156

HDU 1754 I Hate It 线段树RMQ

很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。 这让很多学生很反感。 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。

细语呢喃 1152

PyTorch实战:卷积神经网络详解+Python实现卷积神经网络Cifar10彩色图片分类

PyTorch可以说是三大主流框架中最适合初学者学习的了,相较于其他主流框架,PyTorch的简单易用性使其成为初学者们的首选。这样我想要强调的一点是,框架可以类比为编程语言,仅为我们实现项目效果的工具,也就是我们造车使用的轮子,我们重点需要的是理解如何使用Torch去实现功能而不要过度在意轮子是要怎么做出来的,那样会牵扯我们太多学习时间。以后就出一系列专门细解深度学习框架的文章,但是那是较后期我们对深度学习的理论知识和实践操作都比较熟悉才好开始学习,现阶段我们最需要的是学会如何使用这些工具。

master_hunter的博客 8950

hdu1754 I Hate It 线段树RMQ

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1754题意:题解:线段树RMQ,单点更新,区间查询最大值代码:#include <bits/stdc++.h> using namespace std; typedef long long ll; #define MS(a) memset(a,0,sizeof(a)) #define MP make_pa

yxg_123的博客 241

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

HDU 1754 I Hate It(线段树解决RMQ问题)

思路: 这是线段树的裸题,可以解决区间最大/最小值查询、点修改问题; 如果涉及区间修改,那就需要采用lazy方法了~ 代码: #include<iostream> #include<algorithm> using namespace std; const int MAX_N=2e5+5; int n,m,N; int dat[MAX_N<<2]; voi...

Yuhan的博客 187

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

hdu1754 - I Hate It(线段树RMQ)

I Hate ItTime Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 69021 Accepted Submission(s): 26782Problem Description 很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到

412

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

hdu1754-I Hate It 线段树RMQ算法求区间最值问题

I Hate It Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 77458    Accepted Submission(s): 29801 Problem Description 很多学校流行一种比较的习惯。

wangheng 489

算法模板之RMQ线段树(HDU 1754 I Hate It)

RMQ (Range Minimum/Maximum Query)问题是指:对于长度为n的数列A,回答若干询问RMQ(A,i,j)(i,j&lt;=n),返回数列A中下标在i,j里的最小(大)值,也就是说,RMQ问题是指求区间最值的问题。模板总结归纳:const int MAXNODE = 1 &lt;&lt; 19; const int MAXN = 2e6 + 10; struct NODE...

摸不着脑子的博客 273

HDU-1754-I hate it (线段树RMQ)

建树,修改,求值。。 #include #include #define LL(x) x<<1 #define RR(x) x<<1|1 using namespace std; const int maxn=2e5+7; const int INF=-1e9+7; int a[maxn<<2]; void build(int now,int l,int r) { if(l==r)

On the way 312

HDU - 1754 I Hate It(线段树求RMQ)

给你一个区间,求这个区间的最大值,并且要进行点更新,跟区间更新没什么区别的,不过涉及到区间更新,属于动态RMQ,静态RMQ有更简单的做法(https://blog.csdn.net/qq_38367681/article/details/81143373),本题代码如下: #include &lt;iostream&gt; #include &lt;algorithm&gt; #include...

qq_38367681的博客 214

hdu 1754:I Hate It(线段树,入门题,RMQ问题)

I Hate It Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 33726    Accepted Submission(s): 13266 Problem Description 很多学校流行一种比较的习惯。老师们很喜欢询问,从...

weixin_33911824的博客 77
上一篇: UVa 11151 Longest Palindrome (另一种最长回文&LCS)
下一篇: POJ 3264 Balanced Lineup (RMQ线段树)
synapse7
博客等级 码龄14年 432粉丝 701原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址