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 ...
随机推荐
- Kernel Stack Overflow(转)
0x00 漏洞代码 stack_smashing.c #include <linux/init.h> #include <linux/module.h> #include &l ...
- Bootstrap历练实例:导航内下拉菜单的用法
<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ...
- shell脚本,计算学生分数的题目。
1.计算学生平均分数的值是多少? 2.计算每门课都大于80分的学生姓名.3.计算每门课都小于90分的学生姓名.
- java在线聊天项目0.8版 实现把服务端接收到的信息返回给每一个客户端窗口中显示功能
迭代器的方式会产生锁定 服务器端增加发送给每个客户端已收到信息的功能 所以当获取到一个socket,并打开它的线程进行循环接收客户端发来信息时,我们把这个内部类的线程Client保存到集合List&l ...
- 使用一位数组解决 1 1 2 3 5 8 13 数列问题 斐波纳契数列 Fibonacci
斐波纳契数列 Fibonacci 输出这个数列的前20个数是什么? 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 使用数组实现输出数列的前30 ...
- POJ-3669-流星雨
这题的话,卡了有两个小时左右,首先更新地图的时候越界了,我们进行更新的时候,要判断一下是不是小于零了,越界就会Runtime Error. 然后bfs 的时候,我没有允许它搜出300以外的范围,然后就 ...
- Linux基础学习-使用DHCP动态管理主机地址
动态主机配置协议 部署dhcpd服务程序 参数 作用 ddns-update-style none; 设置DNS服务不自动进行动态更新 ignore client-updates; 忽略客户端更新DN ...
- python入门(一)作业
一,流程控制之if...else 1. 如果:女人的年龄>30岁,那么:叫阿姨,否则:叫小妞 age_of_girl = 21 if age_of_girl >30: print('阿姨' ...
- clock gate
clock gate 这个专题,比较复杂设计DC PT PR.下面仅仅从RTL行为级说明一下.
- 5.电影搜索之 自动填充,也叫autocomplete、搜索建议!
什么叫自动填充,用过百度的应该都知道!当你输入关键词之后,会有一个下拉的候选列表,都是与你输入的内容相关的,这个就是自动填充的搜索建议.一般的搜索引擎或者站内搜索都会有这个功能. 今天分享下这个功能的 ...