原题链接:http://acm.uestc.edu.cn/problem.php?pid=1730

分析:线段树单点更新,区间求和。

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define maxn 500005
#define mod 1000007
using namespace std;
int sum[maxn<<];
int x[maxn];
void build(int l,int r,int rt)
{
if(l==r)
{
sum[rt]=x[l];
return;
}
int m=(l+r)>>;
build(l,m,rt<<);
build(m+,r,rt<<|);
sum[rt]=sum[rt<<]^sum[rt<<|];
}
void update(int l,int r,int rt,int ii,int v)
{
if(l==r&&l==ii){
sum[rt]=v;
return;
}
int m=(l+r)>>;
if(ii<=m)update(l,m,rt<<,ii,v);
else update(m+,r,rt<<|,ii,v);
sum[rt]=sum[rt<<]^sum[rt<<|];
}
int get_sum(int L,int R,int l,int r,int rt)
{
if(L<=l&&r<=R)return sum[rt];
int m=(l+r)>>;
int res=;
if(L<=m)res^=get_sum(L,R,l,m,rt<<);
if(R>=m+)res^=get_sum(L,R,m+,r,rt<<|);
return res;
}
int main()
{
int n,m;
cin>>n>>m;
for(int i=;i<=n;i++)
scanf("%d",&x[i]);
build(,n,);
int i,j;char op[];
while(m--)
{
scanf("%s %d %d",op,&i,&j);
if(op[]=='Q')
{
printf("%d\n",get_sum(i,j,,n,));
}
else update(,n,,i,j);
}
return ;
}

UESTC--1730的更多相关文章

  1. ACM:UESTC - 649 括号配对问题 - stack

      UESTC - 649  括号配对问题 Time Limit: 1000MS   Memory Limit: 65535KB   64bit IO Format: %lld & %llu ...

  2. UESTC 1015 Lweb and pepper --前,后缀最值

    题意: n种食物,每种含花椒的概率为Pi,现在已经选择了[L,R]这个区间(下标)的食物,要再选一个,使总的食物只有一种含花椒的概率最大,问选哪个最好,相同的选下标小的. 解法: 就不写解法了.此处有 ...

  3. UESTC 1852 Traveling Cellsperson

    找规律水题... Traveling Cellsperson Time Limit: 1000ms Memory Limit: 65535KB This problem will be judged ...

  4. UESTC 1851 Kings on a Chessboard

    状压DP... Kings on a Chessboard Time Limit: 10000ms Memory Limit: 65535KB This problem will be judged ...

  5. UESTC 30 最短路,floyd,水

    最短路 Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Submit Statu ...

  6. uestc oj 1218 Pick The Sticks (01背包变形)

    题目链接:http://acm.uestc.edu.cn/#/problem/show/1218 给出n根木棒的长度和价值,最多可以装在一个长 l 的容器中,相邻木棒之间不允许重叠,且两边上的木棒,可 ...

  7. uestc oj 1217 The Battle of Chibi (dp + 离散化 + 树状数组)

    题目链接:http://acm.uestc.edu.cn/#/problem/show/1217 给你一个长为n的数组,问你有多少个长度严格为m的上升子序列. dp[i][j]表示以a[i]结尾长为j ...

  8. bzoj 3196 Tyvj 1730 二逼平衡树(线段树套名次树)

    3196: Tyvj 1730 二逼平衡树 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1807  Solved: 772[Submit][Stat ...

  9. 2015 CCPC D- Pick The Sticks(UESTC 1218) (01背包变形)

    http://acm.uestc.edu.cn/#/problem/show/1218 既然二维dp表示不了,就加一维表示是否在边界放置,放置一个,两个.有一个trick就是如果只放一根,那么多长都可 ...

  10. 2015 CCPC-C-The Battle of Chibi (UESTC 1217)(动态规划+树状数组)

    赛后当天学长就说了树状数组,结果在一个星期后赖床时才有了一点点思路…… 因为无法提交,不确定是否正确..嗯..有错希望指出,谢谢... 嗯..已经A了..提交地址http://acm.uestc.ed ...

随机推荐

  1. Scala基础知识笔记2

    1 类 1.1 定义一个简单的类 1.2 field的getter 和 setter方法 感觉成员变量定义成  var 属性名=属性值即可,  不需要定义成 val 或者 private就行, // ...

  2. CSP201512-2:消除类游戏

    引言:CSP(http://www.cspro.org/lead/application/ccf/login.jsp)是由中国计算机学会(CCF)发起的"计算机职业资格认证"考试, ...

  3. openstack系列文章(三)

    学习openstack的系列文章-glance glance 基本概念 glance 架构 openstack CLI Troubleshooting 1. glance 基本概念 在 opensta ...

  4. 杂谈微服务架构下SSO&OpenAPI访问的方案。

    本篇杂谈下微服务架构下WEB应用的浏览器与OpenAPI访问架构与方案.读者可对比传统架构下应用的此话话题的区别.或者有其它方案的欢迎交流

  5. android开发问题 Failed to pull selection 菜鸟记录

    在eclipse中开发创建了一个sqlite数据库文件,为了查看数据库文件的内容,决定复制到PC上一看究竟,位置在data……里 当我点击ddms文件浏览里的pull a file from the ...

  6. Python 代码调试技巧

    使用 pdb 进行调试 pdb 是 python 自带的一个包,为 python 程序提供了一种交互的源代码调试功能,主要特性包括设置断点.单步调试.进入函数调试.查看当前代码.查看栈片段.动态改变变 ...

  7. CF 1008B Turn the Rectangles(水题+贪心)

    There are n rectangles in a row. You can either turn each rectangle by 90 degrees or leave it as it ...

  8. Scrum立会报告+燃尽图(Beta阶段第二周第三次)

    此作业要求参见:https://edu.cnblogs.com/campus/nenu/2018fall/homework/2411 项目地址:https://coding.net/u/wuyy694 ...

  9. UVALive - 6916 Punching Robot Lucas+dp

    题目链接: http://acm.hust.edu.cn/vjudge/problem/96344 Punching Robot Time Limit: 1000MS64bit IO Format: ...

  10. 关《我是IT小小鸟》有感

    我一直认为大学就是一个自由的舒适的学习环境,没有人可以干扰你限制你,以至于我到了大学之后只剩下了颓废的生活.每天上课玩手机,下课玩电脑,吃饭叫外卖,从不去锻炼,周末就熬夜通宵,状态越来越差,导致我逐渐 ...