2016icpc沈阳站网络赛 1001&hdu5892 Resident Evil

题意:区间异或。

分析:用一个long long 存下50种怪物的情况,然后跑一下二维树状数组。

坑:行末有空格。

吐槽:反正我被自己坑了。

/************************************************
Author        :DarkTong
Created Time  :2016/9/18 21:49:37
File Name     :hdu_5892.cpp
*************************************************/

#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const double eps = 1e-9;
const int maxn = 3005;
LL a[maxn][maxn], b[maxn][maxn], c[maxn][maxn], d[maxn][maxn];
int n, m;
inline int lowbit(int &x){ return x&-x;}
inline void gp(LL e[][maxn], int x, int y, int z)
{
    LL t = (1LL<<z);
    for(int i=x;i<=n;i+=lowbit(i))
        for(int j=y;j<=n;j+=lowbit(j))
            e[i][j] ^= t;
}
//[1-x][1-y]
void Update(int x, int y, int z)
{
    gp(a, x, y, z);
    if(x&1) gp(b, x, y, z);
    if(y&1) gp(c, x, y, z);
    if(x&y&1) gp(d, x, y, z);
}
void Update_T(int x1, int y1, int x2, int y2, int z)
{
    Update(x1, y1, z);
    Update(x2+1, y1, z);
    Update(x1, y2+1, z);
    Update(x2+1, y2+1, z);
}
inline LL gs(LL e[][maxn], int x, int y)
{
    LL ans = 0;
    for(int i=x;i>0;i-=lowbit(i))
        for(int j=y;j>0;j-=lowbit(j))
            ans ^= e[i][j];
    return ans;
}
LL Query(int x, int y)
{
    LL ans = 0;
    ans ^= (((x+1)&(y+1)&1) ? gs(a, x, y) : 0);
    ans ^= (((y+1)&1) ? gs(b, x, y) : 0);
    ans ^= (((x+1)&1) ? gs(c, x, y) : 0);
    ans ^= gs(d, x, y);
    return ans;
}
LL Query_T(int x1, int y1, int x2, int y2) //返回值写错了,查了好久
{
    LL ans = 0;
    ans ^= Query(x2, y2);
    ans ^= Query(x1-1, y2);
    ans ^= Query(x2, y1-1);
    ans ^= Query(x1-1, y1-1);
    return ans;
}

int main()
{
    int T, cas=1;
    scanf("%d%d", &n, &m);
    char op[5];
    int x1, x2, y1, y2, k, a, b;
    while(m--)
    {
        scanf("%s%d%d%d%d", op, &x1, &y1, &x2, &y2);
        if(op[0]=='P')
        {
            scanf("%d", &k);
            while(k--)
            {
                scanf("%d%d", &a, &b);
                if(b&1) Update_T(x1, y1, x2, y2, a-1);
            }
        }
        else
        {
            LL ans = Query_T(x1, y1, x2, y2);
            for(int i=0;i<50;++i) printf("%d ", ((ans>>i)&1LL) ? 2 : 1); puts("");
        }
    }
    return 0;
}

转载于:https://www.cnblogs.com/DarkTong/p/5886612.html

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值