题目大意:给定一个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. Python基础篇 -- if while 语句

    2.7 if语句 # 单纯if if 条件: 代码块 当条件成立,执行代码块 # 二选一 if 条件: 代码块1 else: 代码块2 #当条件为真,执行代码块1,否则执行代码块2 # 多选一 没有e ...

  2. Jarvis OJ-Level4

    借助DynELF实现无libc的漏洞利用小结 #!/usr/bin/env python # coding:utf-8 from pwn import * elf = ELF('level4') wr ...

  3. Spring框架bean的注解管理方法之一 使用注解生成对象

    首先在原有的jar包: 需Spring压缩包中的四个核心JAR包 beans .context.core 和expression 下载地址: https://pan.baidu.com/s/1qXLH ...

  4. 重置windows用户漫游配置文件

    1.备份用户数据 2.删除或修改漫游配置文件 3.用户PC管理员登陆,删除本地用户缓存文件 注册表打开: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows N ...

  5. 编写testplan

    编写验证计划是验证工作核心技能.衡量标准是完备性.可是写一个完备的验证计划,才开始不是一件容易的事情,需要不断的练习实践. 1.验证计划主要从设计的futurelist中提取.     复杂的futu ...

  6. python logging with yaml

    Recently, I was made a service which can provide a simple way to get best model. so, i spent lot of ...

  7. leetcode刷题——查找

    知识点 备忘-必备算法 题目 顺序查找 二分查找 树表搜索 广度优先搜索算法(BFS) 深度优先搜索算法(DFS) 回溯(Backtracking) 题解 CS-Notes Algorithm_Int ...

  8. python基础-面向对象(装饰器)

    属性:   @property   @method_name.setter   @method_name.deleter   三个标签都是放在方法的上面来使用,且方法名要和后续使用的   变量名字相一 ...

  9. java编程思想阅读记录

    第五章:初始化与清理 1.构造器确保初始化 构造器采用与类名相同的方法. 创建对象时,将会为对象分配存储空间,并调用相应的构造器.这就确保了在你能操作对象之前,它就已经恰当的被初始化了. 垃圾回收器负 ...

  10. UTF-8转字典

      NSString *textStr = ] forKey:[string substringToIndex:range.location]];     }];     NSLog(@"% ...