You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
796 B

#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, m;
// 树状数组模板
typedef long long LL;
#define lowbit(x) (x & -x)
int c[N];
void add(int x, int d) {
for (int i = x; i < N; i += lowbit(i)) c[i] += d;
}
LL sum(int x) {
LL res = 0;
for (int i = x; i; i -= lowbit(i)) res += c[i];
return res;
}
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= m; i++) {
int t, x, y;
scanf("%d", &t);
if (t == 1) {
scanf("%d%d", &x, &y);
add(x, 1), add(y + 1, -1); // 用差分数组+树状数组,模拟区间修改
} else {
scanf("%d", &x);
printf("%d\n", sum(x) % 2); // 单点查询,是否变化
}
}
return 0;
}