hdu 3584

OJ

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <list>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

#define PF(x) (scanf("%d",&x))
#define PT(x,y) (scanf("%d%d",&x,&y))
#define PR(x) (printf("%d\n",x))
#define PRT(x,y)(printf("%d %d\n",x,y))
#define M 105

int arr[M][M][M];
int n,m;

int maxx(int x,int y)
{
	return x>y?x:y;
}
int minx(int x,int y)
{
	return x>y?y:x;
}
int low(int x)
{
	return x&(-x);
}
void add(int x,int y,int z,int c)
{
	int t=y;
	int tt = z;
	for(x;x<M;x+=low(x))
		for(t = y;t<M;t+=low(t))
			for(tt = z;tt<M;tt+=low(tt))
			arr[x][t][tt]+=c;
}
int sums(int x,int y,int z)
{
	int sumt = 0;
	int t;
	int tt;
	for(;x;x-=low(x))
		for(t=y;t;t-=low(t))
			for(tt = z;tt;tt-=low(tt))
			sumt += arr[x][t][tt];
	return sumt;
}

void init()
{
	int q;
	while(scanf("%d%d",&n,&m)!=EOF)
	{
		memset(arr,0,sizeof(arr));
		char ch[10];
		int x,y,z,xx,yy,zz;
		for(int i=0;i<m;i++){
		scanf("%s",ch);
		if(ch[0] == '1')
		{
			scanf("%d%d%d%d%d%d",&x,&y,&z,&xx,&yy,&zz);
			add(x,y,z,1);xx++,yy++,zz++;
			add(xx,y,z,-1);add(x,yy,z,-1);add(x,y,zz,-1);
			add(xx,yy,z,1);add(xx,y,zz,1);add(x,yy,zz,1);
			add(xx,yy,zz,-1);
		}
		else 
		{
			scanf("%d%d%d",&x,&y,&z);
			printf("%d\n",sums(x,y,z)%2?1:0);
		}
		}
	}
	return ;
}
int main()
{
	init();
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值