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

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

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

算得上经典题:

 #include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<iostream>
#include<set> using namespace std;
typedef long long ll;
int n; ll c[][][][]; ll query(int x,int y)
{
ll ret=;
for (int i=x;i>;i-=i&-i)
for (int j=y;j>;j-=j&-j)
ret^=c[x&][y&][i][j];
return ret;
} void update(int x,int y,ll v)
{
for (int i=x;i<=n;i+=i&-i)
for (int j=y;j<=n;j+=j&-j)
c[x&][y&][i][j]^=v;
} int main()
{
int m,x,y,xx,yy,op;
ll v;
scanf("%d%d",&n,&m);
while (m--)
{
scanf("%d%d%d%d%d",&op,&x,&y,&xx,&yy);
if (op==)
{
x--;
y--;
printf("%I64d\n",query(x,y)^query(x,yy)^query(xx,y)^query(xx,yy));
}
else
{
scanf("%I64d",&v);
xx++;
yy++;
update(x,y,v);
update(xx,yy,v);
update(x,yy,v);
update(xx,y,v);
}
}
return ;
}

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. shelll脚本,常见的脚本题目。

    [root@localhost wyb]# cat 2quan.sh #!/bin/bash #写一个脚本,先要求输入用户名,然后让他输入一个数字,输的如果是数字给输出yes,不是数字,输出no #然 ...

  2. iOS使用技巧---高效使用你的xcode

    推荐一遍好文章:绝对可以学到关于xcode的很多哟 转载自cocoachina: http://www.cocoachina.com/ios/20140731/9284.html

  3. GIMP永久保存选择的办法

    选择选区,然后把选区放到channel里面去 这是一张已经选择好的选区的图片 然后选择select下的Save to Channel, 需要这部分选区的话,只需要点击这个按钮就可以了

  4. webpack-dev-server proxy代理

    一个最简单的代理例子:index.html中有如下代码 fetch('/api/pub/article/list?pageSize=2').then((data)=>{ return data. ...

  5. 【bug】 1118 Row size too large

    1118 Row size too large Every table (regardless of storage engine) has a maximum row size of 65,535 ...

  6. STM32中如何对printf函数重定向

    通过USART1向计算机的串口调试助手打印数据,或者接收计算机串口调试助手的数据,接下来我们现STM32工程上的printf()函数,方便用于程序开发中调试信息的打印. 方法一:使用MicroLIB库 ...

  7. 织梦dedecms自定义表单设置必填项

    1. 用php验证 在plus/diy.php的第 40行下加 //增加必填字段判断 if($required!=''){ if(preg_match('/,/', $required)) { $re ...

  8. 使用adb命令启查看已安装的Android应用的versionCode、versionName

    列出已经安装的应用 adb shell pm list package C:\Users\CJTDEV003>adb shell pm list package package:com.sams ...

  9. 【bzoj3956】Count 单调栈+可持久化线段树

    题目描述 输入 输出 样例输入 3 2 0 2 1 2 1 1 1 3 样例输出 0 3 题解 单调栈+可持久化线段树 本题是 bzoj4826 的弱化版(我为什么做题总喜欢先挑难的做QAQ) $k$ ...

  10. BZOJ 2140 稳定婚姻 ——二分图

    论二分图的可行边与必须边. 考虑用dinic增广之后的图,一些是必要的割边,一些是可行的割边. 我们首先求出一组可行的最大匹配,那么这些变都是可行的. 然后我们求一遍强连通分量. 如果 scc[u]! ...