loj 10117 简单题

 

#include<iostream>
#include<cstdio>
#include<cctype>
using namespace std;
inline int read()
{
    int x=0,f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c)){x=(x<<3)+(x<<1)+(c^48);c=getchar();}
    return x*f;
}
int f[100001],n,m,l,r,t;
inline int lowbit(int x){return x&(-x);}
inline void updata(int x,int i)
{
    for(;i<=n;i+=lowbit(i))
    f[i]+=x;
}
inline int sum(int i)
{
    int ans=0;
    for(;i;i-=lowbit(i))
    ans+=f[i];
    return ans;
}
int main()
{
    n=read();m=read();
    while(m--)
    {
        t=read();
        if(t==1){
            l=read();r=read();
            updata(1,l);updata(-1,r+1);
        }
        if(t==2){
            l=read();
            l=sum(l);
            if(l&1)l=1;
            else l=0;
            printf("%d\n",l);
        }
    }
    return 0;
}
View Code

 

posted @ 2019-09-18 11:21  Frost_Delay  阅读(164)  评论(0编辑  收藏  举报