题目大意:给你一个3维的矩阵,初始化为0
两种操作
1 x1 y1 z1 x2 y2 z2:将(x1,y1,z1) (x2,y2,z2)这个矩阵内的数取非
0 x1 y1 z1:询问(x1,y1,z1)的值

解题思路:三维树状数组的,跟POJ 2155相类似
更新的时候注意下就行了

#include <cstdio>
#include <cstring>
const int N = 110;

int n, m;
int bit[N][N][N];
inline int lowbit(int x) {
    return x & (-x);
}

void Modify(int x, int y, int z) {
    for (int x1 = x; x1 < N; x1 += lowbit(x1))
        for (int y1 = y; y1 < N; y1 += lowbit(y1))
            for (int z1 = z; z1 < N; z1 += lowbit(z1))
                bit[x1][y1][z1]++;
}


int Query(int x, int y, int z) {
    int ans = 0;
    for (int x1 = x; x1; x1 -= lowbit(x1))
        for (int y1 = y; y1; y1 -= lowbit(y1))
            for (int z1 = z; z1; z1 -= lowbit(z1))
                ans += bit[x1][y1][z1];
    return ans;
}

void solve() {
    memset(bit, 0, sizeof(bit));
    int op;
    int x1, y1, z1, x2, y2, z2;
    while (m--) {
        scanf("%d", &op);
        if (op) {
            scanf("%d%d%d%d%d%d", &x1, &y1, &z1, &x2, &y2, &z2);
            Modify(x1, y1, z1);
            Modify(x2 + 1, y2 + 1, z1);
            Modify(x2 + 1, y1, z1);
            Modify(x1, y2 + 1, z1);
            Modify(x1, y1, z2 + 1);
            Modify(x1, y2 + 1, z2 + 1);
            Modify(x2 + 1, y1, z2 + 1);
            Modify(x2 + 1, y2 + 1, z2 + 1);

        }
        else {
            scanf("%d%d%d", &x1, &y1, &z1);
            printf("%d\n", Query(x1, y1, z1) % 2);
        }
    }
}

int main() {
    while (scanf("%d%d", &n, &m) != EOF) solve();
    return 0;
}