Codeforces D. Iahub and Xors
题目大意:给定一个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的更多相关文章
- 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 ...
- CF341D Iahub and Xors
CF341D Iahub and Xors 给定一个 \(n\times n\) 的矩阵,平面异或,求平面异或和 \((n\leq10^3,\ m\leq10^5)\) 树状数组 这里主要是记录一下板 ...
- Iahub and Xors Codeforces - 341D
二维线段树被卡M+T...于是去学二维树状数组区间更新区间查询 树状数组维护数列区间xor的修改.删除(就是把原问题改成一维): 以下p*i实际都指i个p相xor,即(i&1)*pa表示原数列 ...
- Educational Codeforces Round 6 F. Xors on Segments 暴力
F. Xors on Segments 题目连接: http://www.codeforces.com/contest/620/problem/F Description You are given ...
- codeforces 341C Iahub and Permutations(组合数dp)
C. Iahub and Permutations time limit per test 1 second memory limit per test 256 megabytes input sta ...
- codeforces 340E Iahub and Permutations(错排or容斥)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud Iahub and Permutations Iahub is so happy ...
- CodeForces 340E Iahub and Permutations 错排dp
Iahub and Permutations 题解: 令 cnt1 为可以没有限制位的填充数字个数. 令 cnt2 为有限制位的填充数字个数. 那么:对于cnt1来说, 他的值是cnt1! 然后我们对 ...
- CodeForces 340E Iahub and Permutations
容斥原理,组合数. 找出有$cnt$个数字还有没放,那么总方案数就是$cnt!$. 总方案数里面包含了正确的和非正确的,我们需要将非正确的删去. 先删去$1$个数字$a[i]=i$的情况,发现会多删, ...
- CF198 div1 D - Iahub and Xors
简单说就是左边x,y按照奇偶分为四种对于答案的影响都是不相关的 #include<bits/stdc++.h> using namespace std; typedef long long ...
随机推荐
- WPF显示尺寸与设备无关问题
WPF单位 WPF窗口以及其中的所有元素都是用与设备无关的单位进行度量.一个与设备无关的单位被定义为1/96英寸.WPF程序统一用下面一个公式来定义物理单位尺寸: [ 物理单位尺寸(像素)] = [ ...
- 从prototype beandefinition 谈 spring 的关闭流程和 prototype 的特性
背景介绍: 服务端期望使用 面向对象编程, 和 spring 结合的话只能是通过 prototype 的 bean 定义,并通过 getBean 获取. 优雅停机探究: 代码说明: 1. 类关系 Si ...
- makeObjectsPerformSelector用法
亲测 makeObjectsPerformSelector 的用法. - (void)makeObjectsPerformSelector:(SEL)aSelector NS_SWIFT_UNAVAI ...
- Android Studio问题记录
1>Android Studio中module是什么,? 答:Android Studio是基于intellij,跟eclipse不太一样.对应关系如下: intellij的project -- ...
- 继上次编译openwrt之后,添加web界面
上编博客写了关于openwrt编译环境和编译一个默认配置的openwrt系统. 现在我正在做如何添加web界面.(hiwooya自带的luci web) 方法如下: 首先在编译环境中配置 make m ...
- Lecture1 实验过程模型
Part 1 基本概念 因变量:待检验理论重点关注的,受多个变量影响的变量.(实际考察的,结果) 自变量:影响因变量变化的变量. 因子:重点关注的自变量. 控制变量(control variables ...
- 电子邮件中的to、cc、bcc
电子邮件中的to.cc(carbon copy)和bcc(blind carbon copy),分别是收件人.抄送.密送 to 收件人 你想要给其发邮件的人 cc 抄送人 cc和to是一样的,但是cc ...
- luogu2483 【模板】k短路([SDOI2010]魔法猪学院)
模板题 #include <iostream> #include <cstring> #include <cstdio> #include <queue> ...
- 六丶人生苦短,我用python【第六篇】
Python基础之函数 三元运算 三元运算(三目运算),是对简单的条件语句的缩写. # 书写格式 result = 值1 if 条件 else 值2 # 如果条件成立,那么将 “值1” 赋值给resu ...
- Matplotlib基础图形之散点图
Matplotlib基础图形之散点图 散点图特点: 1.散点图显示两组数据的值,每个点的坐标位置由变量的值决定 2.由一组不连续的点组成,用于观察两种变量的相关性(正相关,负相关,不相关) 3.例如: ...