博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
P5057 [CQOI2006]简单题 前缀异或差分/树状数组
阅读量:4562 次
发布时间:2019-06-08

本文共 1419 字,大约阅读时间需要 4 分钟。

好思路,好思路。。。


 

思路:前缀异或差分

提交:1次

题解:区间修改,单点查询,树状数组,如思路$qwq$

#include
#include
using namespace std;#define R register int #define ull unsigned long long#define ll long long#define pause (for(R i=1;i<=10000000000;++i))#define In freopen("NOIPAK++.in","r",stdin)#define Out freopen("out.out","w",stdout)namespace Fread {static char B[1<<15],*S=B,*D=B;#ifndef JACK#define getchar() (S==D&&(D=(S=B)+fread(B,1,1<<15,stdin),S==D)?EOF:*S++)#endifinline int g() { R ret=0,fix=1; register char ch; while(!isdigit(ch=getchar())) fix=ch=='-'?-1:fix; if(ch==EOF) return EOF; do ret=ret*10+(ch^48); while(isdigit(ch=getchar())); return ret*fix;} inline bool isempty(const char& ch) {
return (ch<=36||ch>=127);}inline void gs(char* s) { register char ch; while(isempty(ch=getchar())); do *s++=ch; while(!isempty(ch=getchar()));}} using Fread::g; using Fread::gs;namespace Luitaryi {const int N=100010;int n,m;int c[N];inline int lbt(int x) {
return x&-x;}inline void add(int pos) {
for(;pos<=n;pos+=lbt(pos)) c[pos]^=1;}inline int query(int pos) { R ret=0; for(;pos;pos-=lbt(pos)) ret^=c[pos]; return ret;}inline void main() { n=g(),m=g(); while(m--) { R op=g(),l,r; if(op&1) l=g(),r=g(),add(l),add(r+1); else l=g(),printf("%d\n",query(l)); }}}signed main() { Luitaryi::main(); return 0;}

2019.07.17

转载于:https://www.cnblogs.com/Jackpei/p/11204438.html

你可能感兴趣的文章
views_object / views_db_object
查看>>
底层原理
查看>>
21. Merge Two Sorted Lists
查看>>
shiro设置加密算法源码解析
查看>>
第二次冲刺
查看>>
实验四
查看>>
win8.1镜像制作
查看>>
Windows 服务开发框架介绍 - Topshelf
查看>>
php,字符串(二)
查看>>
easyui validatebox 验证类型
查看>>
编程迷茫时候看一看
查看>>
“ORA-00913: 值过多”、“ORA-00911: 无效字符”
查看>>
编程中的那些容易迷糊的小知识
查看>>
Sizzle前奏
查看>>
Paint Chain HDU - 3980(sg)
查看>>
Chales常用操作
查看>>
C++ 运算符重载<<
查看>>
windows镜像
查看>>
Flask 模板语法
查看>>
spark-2.2.0安装和部署——Spark集群学习日记
查看>>