题目大意:给定一个N*N的区间,1:对(x0,y0,x1,y1)每个直 都xor v;

2: 求(x0,y0,x1,y1)区间的 sum xor;

http://codeforces.com/blog/entry/8755    

算得上经典题:

  1. #include<stdio.h>
  2. #include<algorithm>
  3. #include<math.h>
  4. #include<vector>
  5. #include<string.h>
  6. #include<string>
  7. #include<set>
  8. #include<map>
  9. #include<iostream>
  10. #include<set>
  11.  
  12. using namespace std;
  13. typedef long long ll;
  14. int n;
  15.  
  16. ll c[][][][];
  17.  
  18. ll query(int x,int y)
  19. {
  20. ll ret=;
  21. for (int i=x;i>;i-=i&-i)
  22. for (int j=y;j>;j-=j&-j)
  23. ret^=c[x&][y&][i][j];
  24. return ret;
  25. }
  26.  
  27. void update(int x,int y,ll v)
  28. {
  29. for (int i=x;i<=n;i+=i&-i)
  30. for (int j=y;j<=n;j+=j&-j)
  31. c[x&][y&][i][j]^=v;
  32. }
  33.  
  34. int main()
  35. {
  36. int m,x,y,xx,yy,op;
  37. ll v;
  38. scanf("%d%d",&n,&m);
  39. while (m--)
  40. {
  41. scanf("%d%d%d%d%d",&op,&x,&y,&xx,&yy);
  42. if (op==)
  43. {
  44. x--;
  45. y--;
  46. printf("%I64d\n",query(x,y)^query(x,yy)^query(xx,y)^query(xx,yy));
  47. }
  48. else
  49. {
  50. scanf("%I64d",&v);
  51. xx++;
  52. yy++;
  53. update(x,y,v);
  54. update(xx,yy,v);
  55. update(x,yy,v);
  56. update(xx,y,v);
  57. }
  58. }
  59. return ;
  60. }

Codeforces D. Iahub and Xors的更多相关文章

  1. Codeforces Round #198 (Div. 1) D. Iahub and Xors 二维树状数组*

    D. Iahub and Xors   Iahub does not like background stories, so he'll tell you exactly what this prob ...

  2. CF341D Iahub and Xors

    CF341D Iahub and Xors 给定一个 \(n\times n\) 的矩阵,平面异或,求平面异或和 \((n\leq10^3,\ m\leq10^5)\) 树状数组 这里主要是记录一下板 ...

  3. Iahub and Xors Codeforces - 341D

    二维线段树被卡M+T...于是去学二维树状数组区间更新区间查询 树状数组维护数列区间xor的修改.删除(就是把原问题改成一维): 以下p*i实际都指i个p相xor,即(i&1)*pa表示原数列 ...

  4. Educational Codeforces Round 6 F. Xors on Segments 暴力

    F. Xors on Segments 题目连接: http://www.codeforces.com/contest/620/problem/F Description You are given ...

  5. codeforces 341C Iahub and Permutations(组合数dp)

    C. Iahub and Permutations time limit per test 1 second memory limit per test 256 megabytes input sta ...

  6. codeforces 340E Iahub and Permutations(错排or容斥)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Iahub and Permutations Iahub is so happy ...

  7. CodeForces 340E Iahub and Permutations 错排dp

    Iahub and Permutations 题解: 令 cnt1 为可以没有限制位的填充数字个数. 令 cnt2 为有限制位的填充数字个数. 那么:对于cnt1来说, 他的值是cnt1! 然后我们对 ...

  8. CodeForces 340E Iahub and Permutations

    容斥原理,组合数. 找出有$cnt$个数字还有没放,那么总方案数就是$cnt!$. 总方案数里面包含了正确的和非正确的,我们需要将非正确的删去. 先删去$1$个数字$a[i]=i$的情况,发现会多删, ...

  9. CF198 div1 D - Iahub and Xors

    简单说就是左边x,y按照奇偶分为四种对于答案的影响都是不相关的 #include<bits/stdc++.h> using namespace std; typedef long long ...

随机推荐

  1. iOS开发遇到的坑之四--图片命名不规范

    最近上手并主导一个小项目的研发,在开发地图模块的时候,UI切图给我们使用,他给的图片命名是1.1.1.png 1.1.2.png 1.1.3.png 我也没有多看,就直接打包发给小组成员叫他添加到Im ...

  2. 升级nodejs 与短小的n模块

    要用指令升级nodejs到新版本要先安装n模块 window用不了n模块  可以用 nvm-windows : https://github.com/coreybutler/nvm-windows n ...

  3. (14)zabbix Simple checks基本检测

    1. 开始 Simple checks通常用来检查远程未安装代理或者客户端的服务 使用simple checks,被监控客户端无需安装zabbix agent客户端,zabbix server直接使用 ...

  4. 2019年6月14日 Web框架之Django_07 进阶操作(MTV与MVC、多对多表三种创建方式、前后端传输数据编码格式contentType、ajax、自定义分页器)

    摘要 MTV与MVC 多对多表三种创建方式 ajax ,前后端传输数据编码格式contentType 批量插入数据和自定义分页器 一.MVC与MTV MVC(Model View Controller ...

  5. Python9-模块2-包的进阶-day21

    包是一种通过使用‘.模块名’来组织python模块名称空间的方式. 1. 无论是import形式还是from...import形式,凡是在导入语句中(而不是在使用时)遇到带点的,都要第一时间提高警觉: ...

  6. python库——h5py入门讲解

    本文只是简单的对h5py库的基本创建文件,数据集和读取数据的方式进行介绍,作者刚接触h5py,完全靠看文档自学,如果哪里说的不对,欢迎纠正!如果读者需要进一步详细的学习h5py的更多知识,请参考h5p ...

  7. python基础学习笔记——迭代器

    我们之前一直在用可迭代对象进行操作,那么到底什么是可迭代对象.我们现在就来讨论讨论可迭代对象.首先我们先回顾下我们 熟知的可迭代对象有哪些: str  list   tuple  dic  set  ...

  8. eval() 函数 解析json对象

    eval在js中用来运行以js源码组成的字符串. 可以用来改变全局或者局部变量,例如: var globalEval = eval; //定义全局eval函数别名 var a ='global', b ...

  9. Linux下安装SaltStack

    一.配置yum源和epel源 epel源下载地址:http://pan.baidu.com/s/1o7NJ26u 1.配置yum源 (1)上传操作系统镜像文件来配置yum源,挂载点目录为/yum mk ...

  10. Python 编程要求

    1.添加前缀 #!/usr/bin/env python # -*- coding:utf-8 -*- 2.py文件.函数都要写好注释 3.主函数要加上判断 if __name__ == " ...