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 ...
随机推荐
- iOS开发遇到的坑之四--图片命名不规范
最近上手并主导一个小项目的研发,在开发地图模块的时候,UI切图给我们使用,他给的图片命名是1.1.1.png 1.1.2.png 1.1.3.png 我也没有多看,就直接打包发给小组成员叫他添加到Im ...
- 升级nodejs 与短小的n模块
要用指令升级nodejs到新版本要先安装n模块 window用不了n模块 可以用 nvm-windows : https://github.com/coreybutler/nvm-windows n ...
- (14)zabbix Simple checks基本检测
1. 开始 Simple checks通常用来检查远程未安装代理或者客户端的服务 使用simple checks,被监控客户端无需安装zabbix agent客户端,zabbix server直接使用 ...
- 2019年6月14日 Web框架之Django_07 进阶操作(MTV与MVC、多对多表三种创建方式、前后端传输数据编码格式contentType、ajax、自定义分页器)
摘要 MTV与MVC 多对多表三种创建方式 ajax ,前后端传输数据编码格式contentType 批量插入数据和自定义分页器 一.MVC与MTV MVC(Model View Controller ...
- Python9-模块2-包的进阶-day21
包是一种通过使用‘.模块名’来组织python模块名称空间的方式. 1. 无论是import形式还是from...import形式,凡是在导入语句中(而不是在使用时)遇到带点的,都要第一时间提高警觉: ...
- python库——h5py入门讲解
本文只是简单的对h5py库的基本创建文件,数据集和读取数据的方式进行介绍,作者刚接触h5py,完全靠看文档自学,如果哪里说的不对,欢迎纠正!如果读者需要进一步详细的学习h5py的更多知识,请参考h5p ...
- python基础学习笔记——迭代器
我们之前一直在用可迭代对象进行操作,那么到底什么是可迭代对象.我们现在就来讨论讨论可迭代对象.首先我们先回顾下我们 熟知的可迭代对象有哪些: str list tuple dic set ...
- eval() 函数 解析json对象
eval在js中用来运行以js源码组成的字符串. 可以用来改变全局或者局部变量,例如: var globalEval = eval; //定义全局eval函数别名 var a ='global', b ...
- Linux下安装SaltStack
一.配置yum源和epel源 epel源下载地址:http://pan.baidu.com/s/1o7NJ26u 1.配置yum源 (1)上传操作系统镜像文件来配置yum源,挂载点目录为/yum mk ...
- Python 编程要求
1.添加前缀 #!/usr/bin/env python # -*- coding:utf-8 -*- 2.py文件.函数都要写好注释 3.主函数要加上判断 if __name__ == " ...