好思路,好思路。。。
思路:前缀异或差分
提交: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