就是线段树的单点修改和区间查询。

然而输入打了一个小时才弄清楚。

 #include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define MN 100000
#define R return
#define INF 0x3f3f3f3f
char ch;
inline int read(){
int x = ; ch=getchar();
while(ch < ''||ch > '') ch=getchar();
while(ch >=''&&ch <='') x = x* + ch - '',ch = getchar();
R x ;
}
int tree[MN*+];
int n,q,a[MN+],cha[],cnt,l,r;
void init(int t,int a,int b,int l,int add){
int m=a+(b-a)/;
if(a==b){tree[t]=add;R;}
if(m>=l) init(t<<,a,m,l,add);
if(m<l) init(t<<|,m+,b,l,add);
tree[t]=min(tree[t<<],tree[t<<|]);
}
int query(int t,int a,int b,int l,int r){
if(l<=a&&b<=r) R tree[t];
int m=(a+b)/,ans=INF;
if(l<=m) ans=min(ans,query(t<<,a,m,l,r));
if(m<r) ans=min(ans,query(t<<|,m+,b,l,r));
R ans;
}
void evlos(bool k){
if(k){
l=read();r=read();
printf("%d\n",query(,,n,l,r));
}
if(!k){
cnt=; cha[++cnt]=read();
while(ch==',') cha[++cnt]=read();
cha[++cnt]=cha[];
for(int i=;i<cnt;i++) init(,,n,cha[i],a[cha[i+]]);
int v=a[cha[]];
for(int i=;i+<cnt;i++) a[cha[i]]=a[cha[i+]];
a[cha[cnt-]]=v;
}
}
void solve(){
bool k;
ch=getchar();
while(ch!='q'&&ch!='s') ch=getchar();
if(ch=='q') k=;
if(ch=='s') k=;
while(ch!='(') ch=getchar();
evlos(k);
}
int main(){
n=read();q=read();
for(int i=;i<=n;i++) a[i]=read(),init(,,n,i,a[i]);
while(q--) solve();
R ;
}

——————————————————————————————————————————————————————————

来自Paper Cloud的博客,未经允许,请勿转载,谢谢。

UVA 12299 RMQ with shifts的更多相关文章

  1. UVa 12299 RMQ with Shifts(移位RMQ)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: "Times New ...

  2. UVa 12299 RMQ with Shifts(线段树)

    线段树,没了.. ----------------------------------------------------------------------------------------- # ...

  3. UVA 12299 RMQ with Shifts(线段树:单点更新)

    题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...

  4. HDU 1754 - I Hate It & UVA 12299 - RMQ with Shifts - [单点/区间修改、区间查询线段树]

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1754 Time Limit: 9000/3000 MS (Java/Others) Memory Li ...

  5. 【UVA】12299-RMQ with Shifts(线段树)

    改动的时候因为数据非常小,所以能够直接暴力改动,查询的时候利用线段树即可了. 14337858 option=com_onlinejudge&Itemid=8&page=show_pr ...

  6. TOJ 4325 RMQ with Shifts / 线段树单点更新

    RMQ with Shifts 时间限制(普通/Java):1000MS/3000MS     运行内存限制:65536KByte 描述 In the traditional RMQ (Range M ...

  7. nyoj 568——RMQ with Shifts——————【线段树单点更新、区间求最值】

    RMQ with Shifts 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述     In the traditional RMQ (Range Minimum Q ...

  8. RMQ with Shifts(线段树)

    RMQ with Shifts Time Limit:1000MS     Memory Limit:65535KB     64bit IO Format:%I64d & %I64u Pra ...

  9. C. RMQ with Shifts

    C. RMQ with Shifts Time Limit: 1000ms Case Time Limit: 1000ms Memory Limit: 131072KB   64-bit intege ...

随机推荐

  1. 二 python并发编程之多进程实现

    一 multiprocessing模块介绍 二 process类的介绍 三 process类的使用 四 守护进程 五 进程同步(锁) 六 队列 七 管道 八 共享数据 九 信号量 十 事件 十一 进程 ...

  2. MySQL中的JSON类型

    前言(废话) 昨天抽了点时间在网上搜列了一个开源项目,项目挺完整的,前后台分离还带有微信小程序,我Clone下代码,经过一番倒腾,嘿~还真就跑起来了.在这个过程中,体验了一把VUE项目工程细节,因为之 ...

  3. 小div在大div中垂直居中方式

    代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8 ...

  4. CSS 之 圣杯布局&双飞翼布局

    圣杯布局 和 双飞翼布局 是重要布局方式.两者的功能相同,都是为了实现一个两侧宽度固定,中间宽度自适应的三栏布局. 遵循了以下要点: 两侧宽度固定,中间宽度自适应 中间部分在DOM结构上优先,以便先行 ...

  5. 冠捷显示成功的信息化建设(MES应用案例)

    企业介绍 冠捷科技集团是驰誉全球的大型高科技跨国企业,产品包括彩色显示器( CRT monitor ).液晶显示器( LCD monitor ).液晶电视( LCD-TV )与等离子电视( PDP ) ...

  6. sublime text3常用的一些快捷键

    --------------------------------下面的内容可以打印出来贴在电脑旁提醒自己-------------------- Ctrl + Shift + D  快速复制当前的一行 ...

  7. oracle执行计划(二)----如何查看执行计划

    目录: (一)六种执行计划  (1)explain plan for  (2)set autotrace on  (3)statistics_level=all  (4)dbms_xplan.disp ...

  8. ZMQ应用

    一.  ZeroMQ概述 ZeroMQ是一种基于消息队列的多线程网络库,其对套接字类型.连接处理.帧.甚至路由的底层细节进行抽象,提供跨越多种传输协议的套接字.ZeroMQ是网络通信中新的一层,介于应 ...

  9. asp.net core 默认采用小驼峰命名和自定义模型验证

    services.AddMvc(options => { options.Filters.Add<ApiExceptionAttribute>(); }).SetCompatibil ...

  10. mysql 增加列

    alter table t_zhaosheng_chengji_is_finish add season_id int(4) default '1' not null COMMENT '招生季ID';