#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define MAXN 110
int con[MAXN][MAXN][MAXN], n, m;
int lowbit(int i)
{
return i&(-i);
}
void update(int i, int j, int k, int v = 1)
{
for (int x = i; x <= n; x += lowbit(x)){
for (int y = j; y <= n; y += lowbit(y)){
for (int z = k; z <= n; z += lowbit(z)){
con[x][y][z] ^= v;
}
}
}
}
bool query(int i, int j, int k)
{
int ret = 0;
for (int x = i; x > 0; x -= lowbit(x)){
for (int y = j; y > 0; y -= lowbit(y)){
for (int z = k; z > 0; z -= lowbit(z)){
ret ^= con[x][y][z];
}
}
}
return ret;
}
int main()
{
int x1, y1, z1, x2, y2, z2, op;
while (~scanf ("%d%d", &n, &m)){
memset (con, 0, sizeof(con));
for (int i = 0; i < m; ++i){
scanf ("%d", &op);
if (op){
scanf ("%d%d%d%d%d%d", &x1, &y1, &z1, &x2, &y2, &z2);
update(x1, y1, z1);
update(x1, y1, z2+1);
update(x1, y2+1, z1);
update(x1, y2+1, z2+1);
update(x2+1, y1, z1);
update(x2+1, y1, z2+1);
update(x2+1, y2+1, z1);
update(x2+1, y2+1, z2+1);
}
else {
scanf ("%d%d%d", &x1, &y1, &z1);
printf ("%d\n", query(x1, y1, z1));
}
}
}
return 0;
}
三維樹狀數組
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.