三位树状数组。
/* 3584 */
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cctype>
using namespace std; #define MAXN 105 bool cnt[MAXN][MAXN][MAXN];
int n, m; inline int lowest(int x) {
return x&-x;
} bool sum(int x, int y, int z) {
int i, j, k;
int ret = ; for (i=x; i; i-=lowest(i)) {
for (j=y; j; j-=lowest(j)) {
for (k=z; k; k-=lowest(k)) {
ret += cnt[i][j][k];
}
}
}
return (ret&) ? true:false;
} void update(int x, int y, int z) {
int i, j, k; for (i=x; i<=n; i+=lowest(i)) {
for (j=y; j<=n; j+=lowest(j)) {
for (k=z; k<=n; k+=lowest(k)) {
cnt[i][j][k] = !cnt[i][j][k];
}
}
}
} int main() {
int i, j, k;
int x1, y1, z1, x2, y2, z2; #ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
#endif while (scanf("%d %d", &n, &m)!=EOF) {
memset(cnt, false, sizeof(cnt));
while (m--) {
scanf("%d", &i);
if (i) {
scanf("%d%d%d%d%d%d", &x1,&y1,&z1, &x2,&y2,&z2);
update(x1, y1, z1);
update(x1, y1, z2+);
update(x1, y2+, z2+);
update(x1, y2+, z1);
update(x2+, y1, z1);
update(x2+, y1, z2+);
update(x2+, y2+, z2+);
update(x2+, y2+, z1);
} else {
scanf("%d %d %d", &x1, &y1, &z1);
k = sum(x1, y1, z1);
if (k)
puts("");
else
puts("");
}
}
} return ;
}