hdu-5465-二维BIT+nim
Clarke and puzzle
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 951 Accepted Submission(s): 349
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:
1. 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.
2. Change ci,j to b.
For each test case:
The first line contains three integers n,m,q(1≤n,m≤500,1≤q≤2∗105)
Then n∗m matrix follow, the i row j column is a integer ci,j(0≤ci,j≤109)
Then q lines follow, the first number is opt.
if opt=1, then 4 integers x1,y1,x1,y2(1≤x1≤x2≤n,1≤y1≤y2≤m) follow, represent operation 1.
if opt=2, then 3 integers i,j,b follow, represent operation 2.
1 2 3
1 2
1 1 1 1 2
2 1 2 1
1 1 1 1 2
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.
- #include<bits/stdc++.h>
- using namespace std;
- #define ULL unsigned long long
- #define LL long long
- int c[][];
- int C[][];
- int N,M;
- inline int lowbit(int x){return x&-x;}
- void change(int x,int y,int d){
- for(int i=x;i<=N;i+=lowbit(i))
- for(int j=y;j<=M;j+=lowbit(j))
- C[i][j]^=d;
- }
- int ask(int x,int y){
- int r=;
- for(int i=x;i;i-=lowbit(i))
- for(int j=y;j;j-=lowbit(j))
- r^=C[i][j];
- return r;
- }
- int main(){
- int t,n,m,i,q,j,k,x1,x2,y1,y2;
- scanf("%d",&t);
- while(t--){
- memset(C,,sizeof(C));
- scanf("%d%d%d",&n,&m,&q);
- N=n,M=m;
- for(i=;i<=n;++i){
- for(j=;j<=m;++j){
- scanf("%d",&c[i][j]);
- change(i,j,c[i][j]);
- }
- }
- int opt,d;
- while(q--){
- scanf("%d",&opt);
- if(opt==){
- scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
- int ans=(ask(x2,y2)^ask(x1-,y1-)^ask(x1-,y2)^ask(x2,y1-));
- ans?puts("Yes"):puts("No");
- }
- else{
- scanf("%d%d%d",&x1,&y1,&d);
- change(x1,y1,(d^c[x1][y1]));
- c[x1][y1]=d;
- }
- }
- }
- return ;
- }
hdu-5465-二维BIT+nim的更多相关文章
- HDU 5465 Clarke and puzzle Nim游戏+二维树状数组
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5465 Clarke and puzzle Accepts: 42 Submissions: 26 ...
- HDU 2159 二维费用背包问题
一个关于打怪升级的算法问题.. 题意:一个人在玩游戏老是要打怪升级,他愤怒了,现在,还差n经验升级,还有m的耐心度(为零就删游戏不玩了..),有m种怪,有一个最大的杀怪数s(杀超过m只也会删游戏的.. ...
- hdu 4819 二维线段树模板
/* HDU 4819 Mosaic 题意:查询某个矩形内的最大最小值, 修改矩形内某点的值为该矩形(Mi+MA)/2; 二维线段树模板: 区间最值,单点更新. */ #include<bits ...
- F - F HDU - 1173(二维化一维-思维)
F - F HDU - 1173 一个邮递员每次只能从邮局拿走一封信送信.在一个二维的直角坐标系中,邮递员只能朝四个方向移动,正北.正东.正南.正西. 有n个需要收信的地址,现在需要你帮助找到一个地方 ...
- HDU 3496 (二维费用的01背包) Watch The Movie
多多想看N个动画片,她对这些动画片有不同喜欢程度,而且播放时长也不同 她的舅舅只能给她买其中M个(不多不少恰好M个),问在限定时间内观看动画片,她能得到的最大价值是多少 如果她不能在限定时间内看完买回 ...
- hdu 2642 二维树状数组 单点更新区间查询 模板水题
Stars Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 32768/65536 K (Java/Others) Total Subm ...
- hdu 2888 二维RMQ模板题
Check Corners Time Limit: 2000/10000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- Coconuts HDU - 5925 二维离散化 自闭了
TanBig, a friend of Mr. Frog, likes eating very much, so he always has dreams about eating. One day, ...
- HDU 1263 二维map
题意:给出一份水果的交易表,根据地区统计出水果的交易情况. 思路:二维map使用. #include<cstdio> #include<string> #include ...
- hdu 2888 二维RMQ
Check Corners Time Limit: 2000/10000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
随机推荐
- web前端----jQuery事件
事件 常用事件 click(function(){...}) hover(function(){...}) blur(function(){...}) focus(function(){...}) c ...
- web前端----JavaScript的DOM(一)
一.什么是HTML DOM HTML Document Object Model(文档对象模型) HTML DOM 定义了访问和操作HTML文档的标准方法 HTML DOM 把 HTML 文档呈现 ...
- (iOS)关于键盘遮挡textfield问题
记录一下自己经常遇到问题.使用textfield(textview).当输入框位置比较靠下时,弹出的键盘会遮挡输入框,这是就需要动态移动输入框编辑状态时self.view的位置, 自己经常用的方法有两 ...
- 原生JS操作AJAX
1,get方式的AJAX function sendAjaxReq() { //1,创建ajax引擎 XMLHttpRequest对象 var req = new XMLHttpRequest() | ...
- Removing bad blocks from the USB drive with fsck
An easy way to repair a flash drive, or any drive really, is to use the fsck tool. This tool is grea ...
- Linux多线程--使用信号量同步线程【转】
本文转载自:http://blog.csdn.net/ljianhui/article/details/10813469 信号量.同步这些名词在进程间通信时就已经说过,在这里它们的意思是相同的,只不过 ...
- spring boot 使用@ConfigurationProperties
有时候有这样子的情景,我们想把配置文件的信息,读取并自动封装成实体类,这样子,我们在代码里面使用就轻松方便多了,这时候,我们就可以使用@ConfigurationProperties,它可以把同类的配 ...
- 【镜像地址】Maven地址列表
1.国内OSChina提供的镜像,非常不错 <mirror> <id>CN</id> <name>OSChina Central</name> ...
- IDEA快捷键复习使用
https://www.jetbrains.com/help/idea/meet-intellij-idea.html 快捷键可以极快地进行代码编辑整理,在IDEA的快捷键中,除了有几个好像特别难按之 ...
- 到底二级域名和一级域名哪个更利于SEO
到底二级域名和一级域名哪个更利于SEO呢?本文是从百度官方转载详细的介绍:二级域名和一级域名的区别,请各位认真阅读. 二级域名和子域名的区别可以通过以下3点来解读: 一,二级域名的特点 搜索引擎往往将 ...