#include
<
iostream
>
using
namespace
std;
int
n,m;
int
cc[
100010
],c[
100010
];
int
bo[
100010
];
inline
int
lowbit(
int
x){
return
x
&
(
-
x);
}
void
modify1(
int
x){
while
(x
<=
100000
){
cc[x]
++
;
x
+=
lowbit(x);
}
}
void
modify(
int
x,
int
s){
while
(x
<=
100000
){
c[x]
+=
s;
x
+=
lowbit(x);
}
}
int
getsum(
int
x){
int
s
=
0
;
while
(x){
s
+=
c[x];
x
-=
lowbit(x);
}
return
s;
}
int
main()
{
for
(
int
i
=
1
;i
<=
100000
;
++
i)
cc[i]
=
0
;
for
(
int
i
=
1
;i
<=
100000
;
++
i)
modify1(i);
int
t;
scanf(
"
%d
"
,
&
t);
while
(t
--
){
scanf(
"
%d%d
"
,
&
n,
&
m);
for
(
int
i
=
1
;i
<=
n;
++
i){
c[i]
=
cc[i];
bo[i]
=
1
;
}
while
(m
--
){
int
k,x,y;
scanf(
"
%d
"
,
&
k);
if
(k){
scanf(
"
%d%d
"
,
&
x,
&
y);
if
(x
>
y){
int
tmp
=
x;
x
=
y;y
=
tmp;
}
int
s
=
getsum(y
-
1
)
-
getsum(x
-
1
);
if
(s
==
y
-
x)
printf(
"
1\n
"
);
else
{
s
=
getsum(n)
-
s;
if
(s
==
n
-
(y
-
x))
printf(
"
1\n
"
);
else
printf(
"
0\n
"
);
}
}
else
{
scanf(
"
%d
"
,
&
x);
if
(bo[x])
modify(x,
-
1
);
else
modify(x,
1
);
bo[x]
=
1
-
bo[x];
}
}
}
return
0
;
}
posted on 2009-05-02 08:49
xfstart07 阅读(154)
评论(0) 编辑 收藏 引用 所属分类:
代码库