Problem Description
Clarke is a patient with multiple personality disorder. One day, Clarke split into two personality a and b, they are playing a game.
There is a n∗m matrix, each grid of this matrix has a number ci,j.
a wants to beat b every time, so a ask you for a help.
There are q operations, each of them is belonging to one of the following two types:
. They play the game on a (x1,y1)−(x2,y2) sub matrix. They take turns operating. On any turn, the player can choose a grid which has a positive integer from the sub matrix and decrease it by a positive integer which less than or equal this grid's number. The player who can't operate is loser. a always operate first, he wants to know if he can win this game.
. Change ci,j to b.

Input
The first line contains a integer T(≤T≤), the number of test cases.
For each test case:
The first line contains three integers n,m,q(≤n,m≤,≤q≤∗)
Then n∗m matrix follow, the i row j column is a integer ci,j(≤ci,j≤)
Then q lines follow, the first number is opt.
if opt=, then integers x1,y1,x1,y2(≤x1≤x2≤n,≤y1≤y2≤m) follow, represent operation .
if opt=, then integers i,j,b follow, represent operation .
 
Output
For each testcase, for each operation , print Yes if a can win this game, otherwise print No.
Sample Input

Sample Output
Yes
No
Hint:
The first enquiry: $a$ can decrease grid $(1, 2)$'s number by $1$. No matter what $b$ operate next, there is always one grid with number $1$ remaining . So, $a$ wins.
The second enquiry: No matter what $a$ operate, there is always one grid with number $1$ remaining. So, $b$ wins.
 
Source
 

题目要求二维的nim游戏,考虑到nim的结论是xor和为0则必败、否则必胜,那么我们只需要维护子矩阵的xor和。由于xor有前缀和性质,所以我们可以用一个二维bit来维护(1, 1)-(a, b)的矩阵的xor和,然后由sum(x2,y2) xor sum(x2,y1−1) xor sum(x1−1,y2) xor sum(x1−1,y1−1)sum(x2, y2) \ xor \ sum(x2, y1-1) \ xor \ sum(x1-1, y2) \ xor \ sum(x1-1, y1-1)sum(x2,y2) xor sum(x2,y1−1) xor sum(x1−1,y2) xor sum(x1−1,y1−1)来得到答案即可。单点修改在bit上是很容易的。

 #pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<stdlib.h>
#include <stack>
using namespace std;
int dirx[]={,,-,};
int diry[]={-,,,};
#define PI acos(-1.0)
#define max(a,b) (a) > (b) ? (a) : (b)
#define min(a,b) (a) < (b) ? (a) : (b)
#define ll long long
#define eps 1e-10
#define MOD 1000000007
#define N 506
#define inf 1e12
int n,m,q;
int mp[N][N];
int a[N][N];
int main()
{
int t;
scanf("%d",&t);
while(t--){
scanf("%d%d%d",&n,&m,&q);
for(int i=;i<=n;i++){
for(int j=;j<=m;j++){
scanf("%d",&mp[i][j]);
a[i][j]=a[i][j-]^mp[i][j];
}
}
for(int i=;i<q;i++){
int opt;
scanf("%d",&opt);
int x,y,z;
if(opt==){
scanf("%d%d%d",&x,&y,&z);
mp[x][y]=z;
for(int j=y;j<=m;j++){
a[x][j]=a[x][j-]^mp[x][j];
}
}
else{
int ans=;
int x1,y1,x2,y2;
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
for(int j=x1;j<=x2;j++){
ans=ans^(a[j][y2]^a[j][y1-]);
}
if(ans==){
printf("No\n");
}
else{
printf("Yes\n");
}
}
}
}
return ;
}

hdu 5465 Clarke and puzzle(前缀和,异或,nim博弈)的更多相关文章

  1. HDU 5465 Clarke and puzzle Nim游戏+二维树状数组

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5465 Clarke and puzzle  Accepts: 42  Submissions: 26 ...

  2. HDU 5465——Clarke and puzzle——————【树状数组BIT维护前缀和+Nim博弈】

    Clarke and puzzle Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others ...

  3. hdu 5465 Clarke and puzzle 二维线段树

    Clarke and puzzle Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...

  4. BestCoder Round #56 1002 Clarke and problem 1003 Clarke and puzzle (dp,二维bit或线段树)

    今天第二次做BC,不习惯hdu的oj,CE过2次... 1002 Clarke and problem 和Codeforces Round #319 (Div. 2) B Modulo Sum思路差不 ...

  5. 2015北京网络赛 J Clarke and puzzle 求五维偏序 分块+bitset

    Clarke and puzzle Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://hihocoder.com/contest/acmicpc20 ...

  6. HDU 5628 Clarke and math——卷积,dp,组合

    HDU 5628 Clarke and math 本文属于一个总结了一堆做法的玩意...... 题目 简单的一个式子:给定$n,k,f(i)$,求 然后数据范围不重要,重要的是如何优化这个做法. 这个 ...

  7. hdu 1730 Nim博弈

    题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=1730 Nim博弈为:n堆石子,每个人可以在任意一堆中取任意数量的石子 n个数异或值为0就后手赢,否则先 ...

  8. HDU 2509 Nim博弈变形

    1.HDU 2509  2.题意:n堆苹果,两个人轮流,每次从一堆中取连续的多个,至少取一个,最后取光者败. 3.总结:Nim博弈的变形,还是不知道怎么分析,,,,看了大牛的博客. 传送门 首先给出结 ...

  9. HDU 1907 Nim博弈变形

    1.HDU 1907 2.题意:n堆糖,两人轮流,每次从任意一堆中至少取一个,最后取光者输. 3.总结:有点变形的Nim,还是不太明白,盗用一下学长的分析吧 传送门 分析:经典的Nim博弈的一点变形. ...

随机推荐

  1. [每日一题] OCP1z0-047 :2013-07-27 外部表――不能被DML和建索引

    首先看官方文档上的解释: Managing External Tables Oracle Database allows you read-only access to data in externa ...

  2. animation与transition

    animation 动画,无法直接决定开始时间 demo1 @-webkit-keyframes demo-animation1{ 0% { -webkit-transform:translate3d ...

  3. textarea 的最大高度以及最小高度

    <script type="text/javascript"> $(function(){ $("#textarea3").textareaAuto ...

  4. Socket介绍

    一 socket协议 Socket协议的形象描述 socket的英文原义是“孔”或“插座”.在这里作为4BDS UNIX的进程通信机制,取后一种意思.socket非常类似于电话插座.以一个国家级电话网 ...

  5. 关于IIS7.5下的web.config 404 配置的一些问题

    本文介绍一个关于IIS环境下web.config配置的经验问题.在IIS7.5中添加配置404页面时遇到了一些问题,记录如下: 一开始在<customError>下的<error&g ...

  6. BaceModel

    https://github.com/nicklockwood/BaseModel 字典封装成model 自动封装 要求属性的名字与字典一样 不能有对象 如果其中有需要自己封装的对象属性 重写setW ...

  7. c++ 指针的简单用法

    对于指针,其实只需要明白几点就可以. 1.指针,是一个数值为地址的变量,这里尤其注意,指针变量的值是地址!就是例如40002这种像门牌号的地址值,其实就是内存中的一个编号. 2.&,该符号的意 ...

  8. MySQL学习笔记(2) - 修改MySQL提示符的两种方法

    学习于慕课网 http://www.imooc.com/video/1806 1.方法一: cmd中处于未登录状态时,输入 mysql -uroot -p自己的密码 --prompt 新的提示符 示例 ...

  9. 磁盘管理二-LVM相关内容

    1.基本概念 LVM:logical volume manager 逻辑卷管理器 LVM构成:物理卷PV,卷组VG(PE物理区域,最小存储单元),逻辑卷LV(LE逻辑区域,最小存储单元) 三者如下图所 ...

  10. Constructing Roads(1102 最小生成树 prim)

    Constructing Roads Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...