Yes you read that right it really be called simple question
Do not believe you
Title Description
An array of n elements, each element initially are 0. M has instructions, which allow for a continuous sequence or digit reversal becomes 0 --0 variants 1,1 (operation 1), or an element of the challenge value (operation 2). For example, when n = 20, the 10 following instructions:
Input Format
The first line contains two integers n, m, and the length of the bar represents the number of instructions of the array; the m rows, each row of the first number and t represents the type of the operation:
When t = 1, then the next two numbers L, R, representing the interval [L, R] is inverted for each number; if t = 2, only one number is next i, subscript represents inquiry.
Output Format
Each operation of the second output line (i.e. a non-zero), 2 represents the operation of each answer.
Sample input and output
20 10 1 1 10 2 6 2 12 1 5 12 2 6 2 15 1 6 16 1 11 17 2 12 2 6
1 0 0 0 1 1
Description / Tips
For 50% of the data,. 1 ≤ n-≤ 10 ^. 3 . 1 0 . 3,. 1 ≤ m ≤ 10 ^. 4 . 1 0 . 4; 100% of the data,. 1 ≤ n-≤ 10 ^. 5 . 1 0 . 5,. 1 ≤ m ≤. 5 × 10 ^. 5 . 1 0 . 5, to ensure that L ≤ R.
Title source CQOI2006 / Luo Gu P5057
And the principle that a tree outside the school but this problem is to modify a single point of inquiry interval
Also considered for each point by the length of the sequence in parentheses is the method of section 1 can
Note 1 modified once becomes twice becomes 0
The Code
#include<iostream> #include<cstdio> #include<cstring> #define int long long #define lowbit(x) x&(-x) using namespace std; int n,m,t,ll,rr,xx,l[1000050],r[1000050]; void updatal(int i,int x) { while(i<=n) { l[i]+=x; i+=lowbit(i); } } void updatar(int i,int x) { while(i<=n) { r[i]+=x; i+=lowbit(i); } } int queryl(int i) { int res=0; while(i>=1) { res+=l[i]; i-=lowbit(i); } return res; } int queryr(int i) { int res=0; while(i>=1) { res+=r[i]; i-=lowbit(i); } return res; } signed main() { scanf("%lld%lld",&n,&m); for(int i=1;i<=m;i++) { scanf("%lld",&t); if(t==1) { scanf("%lld%lld",&ll,&rr); updatal(ll,1); updatar(rr,1); } if(t==2) { scanf("%lld",&xx); printf("%lld\n",(queryl(xx)-queryr(xx-1))%2); } } return 0; }