UESTC--1730
原题链接: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的更多相关文章
- ACM:UESTC - 649 括号配对问题 - stack
UESTC - 649 括号配对问题 Time Limit: 1000MS Memory Limit: 65535KB 64bit IO Format: %lld & %llu ...
- UESTC 1015 Lweb and pepper --前,后缀最值
题意: n种食物,每种含花椒的概率为Pi,现在已经选择了[L,R]这个区间(下标)的食物,要再选一个,使总的食物只有一种含花椒的概率最大,问选哪个最好,相同的选下标小的. 解法: 就不写解法了.此处有 ...
- UESTC 1852 Traveling Cellsperson
找规律水题... Traveling Cellsperson Time Limit: 1000ms Memory Limit: 65535KB This problem will be judged ...
- UESTC 1851 Kings on a Chessboard
状压DP... Kings on a Chessboard Time Limit: 10000ms Memory Limit: 65535KB This problem will be judged ...
- UESTC 30 最短路,floyd,水
最短路 Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Submit Statu ...
- uestc oj 1218 Pick The Sticks (01背包变形)
题目链接:http://acm.uestc.edu.cn/#/problem/show/1218 给出n根木棒的长度和价值,最多可以装在一个长 l 的容器中,相邻木棒之间不允许重叠,且两边上的木棒,可 ...
- uestc oj 1217 The Battle of Chibi (dp + 离散化 + 树状数组)
题目链接:http://acm.uestc.edu.cn/#/problem/show/1217 给你一个长为n的数组,问你有多少个长度严格为m的上升子序列. dp[i][j]表示以a[i]结尾长为j ...
- bzoj 3196 Tyvj 1730 二逼平衡树(线段树套名次树)
3196: Tyvj 1730 二逼平衡树 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 1807 Solved: 772[Submit][Stat ...
- 2015 CCPC D- Pick The Sticks(UESTC 1218) (01背包变形)
http://acm.uestc.edu.cn/#/problem/show/1218 既然二维dp表示不了,就加一维表示是否在边界放置,放置一个,两个.有一个trick就是如果只放一根,那么多长都可 ...
- 2015 CCPC-C-The Battle of Chibi (UESTC 1217)(动态规划+树状数组)
赛后当天学长就说了树状数组,结果在一个星期后赖床时才有了一点点思路…… 因为无法提交,不确定是否正确..嗯..有错希望指出,谢谢... 嗯..已经A了..提交地址http://acm.uestc.ed ...
随机推荐
- 自然语言处理 - 如何通俗地理解TFIDF?
本博客属个人学习笔记,如有疏漏,欢迎在评论留言指出~转载请注明. 在自然语言处理中,TFIDF常常被人提及.很多材料都提及TFIDF中的“普遍重要性”,但很少有材料去简单解释其中的原理.TFIDF其实 ...
- 华为笔试——C++的int型数字位排序
题目:int型数字位排序 题目介绍:输入int 型整数,按照从右至左的顺序,返回不含重复数字的新整数. 例: 输入: 99824270 输出: 072489 分析:乍一看很简单,但是很容易忽略int ...
- ASP.NET MVC - 启动创建项目,未能加载错误
VS2012以常规方式创建一ASP.NET MVC internet 项目.创建后F5启动项目,遇一错误: 未能加载文件或程序集“MySql.Web.v20, Version=6.9.4.0, Cul ...
- python format用法详解
#常用方法:print('{0},{1}'.format('zhangk', 32)) print('{},{},{}'.format('zhangk','boy',32)) print('{name ...
- js 插件 issue
1 iscroll 5 和 lazyload 同时使用 转自 yinjie //lazyload var $scrollEle = $("#wrapper") $("i ...
- .net学习-扩展
uwp uwpapp-斗鱼,微信等 云和移动优先 远程桌面连接设置 teamviewer V8内核 Node.js javascript 事件循环 express框架 bootstrap NoSQL ...
- webService —— soap
package soupTest; import javax.jws.WebMethod; import javax.jws.WebService; import javax.xml.ws.Endpo ...
- 人生的第一篇blog
开始写博客了,人生第一篇博客啊,要写些什么呢?想想也没有什么头绪,随便写写吧. 这学期要使用代码管理工具了,要写团队项目了.一直以来都是自己一个人在默默编程,没有过合作经历.对于代码的管理也只是一直在 ...
- [并查集] More is Better
题目描述 Mr Wang wants some boys to help him with a project. Because the project is rather complex, the ...
- Tomcat配置 —— server.xml
Tomcat的核心组件是servlet容器. Tomcat各个组件之间的嵌套关系 server.xml配置如下: <Server port="8005" shutdown=& ...