CF198 div1 D - Iahub and Xors
简单说就是左边x,y按照奇偶分为四种对于答案的影响都是不相关的
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e3+5;
int N,M;
ll tree[4][MAXN][MAXN];
int ju(int x, int y) {
int tt = 0;
if(x%2) tt ++;
if(y%2) tt += 2;
return tt;
}
void Update(int x,int y, ll v) {
int ty = ju(x,y);
for(int i = x; i <= N; i += i&-i)
for(int j = y; j <= N; j += j&-j)
tree[ty][i][j] ^= v;
}
ll Sum(int x,int y) {
int ty = ju(x,y);
ll ans = 0;
for(int i = x; i > 0; i -= i&-i)
for(int j = y; j > 0; j -= j&-j)
ans ^= tree[ty][i][j];
return ans;
}
int main(){
while(~scanf("%d %d",&N,&M)) {
memset(tree ,0, sizeof(tree));
for(int i = 1; i <= M; ++i) {
int a,b,c,d; int ty; ll v;
scanf("%d",&ty);
if(ty == 2) {
scanf("%d %d %d %d %lld",&a,&b,&c,&d,&v);
Update(a,b,v);
Update(c+1,b,v);
Update(a,d+1,v);
Update(c+1,d+1,v);
}else {
ll ans = 0;
scanf("%d %d %d %d",&a,&b,&c,&d);
ans ^= Sum(c,d);
ans ^= Sum(a-1,d);
ans ^= Sum(c,b-1);
ans ^= Sum(a-1,b-1);
printf("%lld\n",ans);
}
}
}
return 0;
}
CF198 div1 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)\) 树状数组 这里主要是记录一下板 ...
- 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 ...
- Iahub and Xors Codeforces - 341D
二维线段树被卡M+T...于是去学二维树状数组区间更新区间查询 树状数组维护数列区间xor的修改.删除(就是把原问题改成一维): 以下p*i实际都指i个p相xor,即(i&1)*pa表示原数列 ...
- codeforces 341d (树状数组)
problem Iahub and Xors 题目大意 一个n*n的矩阵,要求支持两种操作. 操作1:将一个子矩阵的所有值异或某个数. 操作2:询问某个子矩阵的所以值的异或和. 解题分析 由于异或的特 ...
- Codeforces Round #198 (Div. 1 + Div. 2)
A. The Wall 求下gcd即可. B. Maximal Area Quadrilateral 枚举对角线,根据叉积判断顺.逆时针方向构成的最大面积. 由于点坐标绝对值不超过1000,用int比 ...
- CF#345 (Div1)
论蒟蒻如何被cf虐 以下是身败名裂后的题解菌=========== Div1 A.Watchmen 有n个点,每个点有一个坐标.求曼哈顿距离=欧几里得距离的点对数量. 只需要统计x或y一样的点对数量. ...
- 图论 SRM 674 Div1 VampireTree 250
Problem Statement You are a genealogist specializing in family trees of vampires. Vampire famil ...
- jq对象转为dom对象:$(".div1")[0] dom对象转为jq对象:$(dom对象)
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>& ...
随机推荐
- bzoj 1598: [Usaco2008 Mar]牛跑步 [k短路 A*] [学习笔记]
1598: [Usaco2008 Mar]牛跑步 题意:k短路 ~~貌似A*的题目除了x数码就是k短路~~ \[ f(x) = g(x) + h(x) \] \(g(x)\)为到达当前状态实际代价,\ ...
- BZOJ 4569: [Scoi2016]萌萌哒 [并查集 倍增]
传送门 题意:长为$n \le 10^5$的数字,给出$m \le 10^5$个限制$[l1,r1]\ [l2,r2]$两个子串完全相等,求方案数 把所有要求相等的位置连起来,不就是$9*10^{连通 ...
- 一个Dotnet数据框架的bug
好久没写C#代码了,今天在维护公司老项目时,偶然发现一个BUG.记录一下,后面的同学就不要踩坑啦. -------------------------------------------------- ...
- Code::Blocks 配置
需要另外下载安装GCC编译器 配置主题皮肤: 先替换' default.conf ' (需要关闭code::blocks) Settings>Editor>(左栏)Syntax highl ...
- [Python Study Notes]字典操作
字典操作 a.增加 >>> info["stu1104"] = "abc" >>> info {'stu1102': 'x5 ...
- MacbookPro管理员问题
更改用户名重启之后,发现用户名还是用户名,管理员权限降成了普通用户. 参考这个帖子改的用户名: https://zhidao.baidu.com/question/259845860.html 找回管 ...
- Three.js 学习笔记(1)--坐标体系和旋转
前言 JavaScript 3D library The aim of the project is to create an easy to use, lightweight, 3D library ...
- 洛谷P1879 [USACO06NOV]玉米田Corn Fields【状压DP】题解+AC代码
题目描述 Farmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ...
- 【JavaWeb】权限管理系统
前言 前面我们做的小项目都是一个表的,业务代码也相对简单.现在我们来做一个权限管理系统,体验一下多表的业务逻辑,顺便巩固一下过滤器的知识.! 目的 现在我有一个管理商品.订单的页面.当用户点击某个超链 ...
- AVFoundation 框架初探究(四)
叨叨两句 动手写这篇总结时候也是二月底过完年回来上班了,又开始新的一年了,今年会是什么样子?这问题可能得年底再回答自己了.在家窝了那么久,上班还是的接着看我们要看的东西,毕竟我们要做的事还真的太多的. ...