题目大意:给定一个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. jpeg和jpg的区别是什么

    JPG是JPEG的简写,jpg是后缀名,jpeg既可作为后缀名,又能代表文件格式:JPG——JPEG文件格式. 我们在系统自带的画图程序里保存文件,在保存类型:JPEG(*.JPG,*.JPEG,*. ...

  2. Bootstrap 网格系统(Grid System)实例1

    Bootstrap 网格系统(Grid System)实例:堆叠水平 <!DOCTYPE html><html><head><meta http-equiv= ...

  3. non-JRMP server at remote endpoint

    #在相应的domain的domain.xml文件添加下面红色设置,并重启domain <admin-service system-jmx-connector-name="system& ...

  4. ios之UISearchBar

    当你在seachBar中输入字母之前的时候,只是用鼠标选中searchBar的时候,如图 终端输出截图如下:(这个时候调用先shouldBeginEditing,之后调用didBeginEditing ...

  5. 51nod 1242 斐波那契数列的第N项——数学、矩阵快速幂

    普通算法肯定T了,所以怎么算呢?和矩阵有啥关系呢? 打数学符号太费时,就手写了: 所以求Fib(n)就是求矩阵  |  1  1  |n-1  第一行第一列的元素. |  1  0  | 其实学过线代 ...

  6. kvm虚拟化存储管理

    1. kvm虚拟化存储介绍 KVM 的存储虚拟化是通过存储池(Storage Pool)和卷(Volume)来管理的.Storage Pool 是宿主机上可以看到的一片存储空间,可以是多种型: Vol ...

  7. Linux配置使用SSH Key登录并禁用root密码登录(替换同理)

    Linux系统大多说都支持OpenSSH,生成公钥.私钥的最好用ssh-keygen命令,如果用putty自带的PUTTYGEN.EXE生成会不兼容OpenSSH,从而会导致登录时出现server r ...

  8. LA 4256 DP Salesmen

    d(i, j)表示使前i个数满足要求,而且第i个数值为j的最小改动次数. d(i, j) = min{ d(i-1, k) | k == j | G[j][k] } #include <cstd ...

  9. ubuntu ssh连接服务器保持长时间不断

    方法: ssh -o serveraliveinterval=60 username@ip

  10. UITableView性能-圆角图片

    圆角图片因为GPU渲染会影响性能 参考:http://www.cocoachina.com/ios/20150803/12873.html http://blog.sina.com.cn/s/blog ...