#include <bits/stdc++.h>
using namespace std ;
int n , m , c[100005] ;
bool a[100005];
int main()
{
cin >> n >> m ;
int p = sqrt( n ) ;
while( m -- )
{
int op , l , r ;
cin >> op >> l >> r ;
int x = ( l - 1 ) / p + 1 , y = ( r - 1 ) / p + 1 ;
if( op == 0 )
{
if( x == y )
{
for( int i = l ; i <= r ; i ++ )
{
if( a[i] == 1 ) c[x] -- ;
else c[x] ++ ;
a[i] ^= 1 ;
}
}
else {
for( int i = l ; i <= x * p ; i ++ )
{
if( a[i] == 1 ) c[x] -- ;
else c[x] ++ ;
a[i] ^= 1 ;
}
for( int i = x + 1 ; i < y ; i ++ )
{
for( int j = ( i - 1 ) * p + 1 ; j <= i * p ; j ++ )
{
a[j] ^= 1 ;
}
c[i] = p - c[i] ;
}
for( int i = ( y - 1 ) * p + 1 ; i <= r ; i ++ )
{
if( a[i] == 1 ) c[y] -- ;
else c[y] ++ ;
a[i] ^= 1 ;
}
}
}
else
{
int sum = 0 ;
if( x == y )
{
for( int i = l ; i <= r ; i ++ )
{
sum += a[i] ;
}
cout << sum << endl ;
continue ;
}
for( int i = l ; i <= x * p ; i ++ )
{
sum += a[i] ;
}
for( int i = x + 1 ; i < y ;i ++ )
{
sum += c[i] ;
}
for( int i = ( y - 1 ) * p ; i <= r ; i ++ )
{
sum += a[i] ;
}
cout << sum << endl ;
}
}
return 0;
}
结果是个0分.....希望有大佬来帮帮我!蟹蟹