#include<stdio.h>
int main()
{
int arr[100001]={0},sum2[1001]={0};
int type[1001]={0};//0 for tails
int N,Q,i,j,sum;
int a,b,c;
scanf("%d",&N);
scanf("%d",&Q);
for(i=0;i<Q;i++)
{
scanf("%d%d%d",&a,&b,&c);
if(a==0)
{
j=b;
int k=j/100;
while(j%100 && j<=c)
{
if(arr[j])
{
arr[j]=!arr[j];
sum2[k]--;
}
else{
arr[j]=!arr[j];
sum2[k]++;
}
j++;
}
while(j+100<=c)
{
type[j/100]=!type[j/100];
j+=100;
}
k=j/100;
while(j<=c)
{
if(arr[j])
{
arr[j]=!arr[j];
sum2[k]--;
}
else{
arr[j]=!arr[j];
sum2[k]++;
}
j++;
}
}
else{
sum=0;
j=b;
int k=j/100;
while(j%100 && j<=c)
{
sum+=arr[j]^type[k];
j++;
}
while(j+100<=c)
{
if(type[j/100])
sum+=100-sum2[j/100];
else
sum+=sum2[j/100];
j+=100;
}
k=j/100;
while(j<=c)
{
sum+=arr[j]^type[k];
j++;
}
printf("%d\n",sum);
}
}
return 0;
}
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.