现在的位置: 首页 > 综合 > 正文

Hdu3584 Cube

2018年04月23日 ⁄ 综合 ⁄ 共 808字 ⁄ 字号 评论关闭

code:

#include <set>
#include <cstring>
#include <cstdio>
using namespace std;

int n,a[105][105][105];
int lowbit(int x)
{
    return x&(-x);
}
void update(int x,int y,int z)
{
    int i,j,k;
    for(i=x;i<=n;i+=lowbit(i))
        for(j=y;j<=n;j+=lowbit(j))
            for(k=z;k<=n;k+=lowbit(k))
                a[i][j][k]++;
}
int getsum(int x,int y,int z)
{
    int i,j,k,sum=0;
    for(i=x;i>0;i-=lowbit(i))
        for(j=y;j>0;j-=lowbit(j))
            for(k=z;k>0;k-=lowbit(k))
                sum+=a[i][j][k];
    return sum&1;
}
int main()
{
    int i,k,m,x1,y1,z1,x2,y2,z2;;
    while(~scanf("%d%d",&n,&m))
    {
        memset(a,0,sizeof(a));
        for(i=1;i<=m;i++)
        {
            scanf("%d",&k);
            if(k==1)
            {
                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",getsum(x1,y1,z1));
            }
        }
    }
    return 0;
}
【上篇】
【下篇】

抱歉!评论已关闭.