CF341D Iahub and Xors】的更多相关文章

CF341D Iahub and Xors 给定一个 \(n\times n\) 的矩阵,平面异或,求平面异或和 \((n\leq10^3,\ m\leq10^5)\) 树状数组 这里主要是记录一下板子--qaq 时间复杂度 \(O(m\log^2n)\) 代码 #include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1010; int n, m, a[maxn][maxn]; l…
D. Iahub and Xors   Iahub does not like background stories, so he'll tell you exactly what this problem asks you for. You are given a matrix a with n rows and n columns. Initially, all values of the matrix are zeros. Both rows and columns are 1-based…
简单说就是左边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(i…
题目大意:给定一个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<st…
二维线段树被卡M+T...于是去学二维树状数组区间更新区间查询 树状数组维护数列区间xor的修改.删除(就是把原问题改成一维): 以下p*i实际都指i个p相xor,即(i&1)*pa表示原数列d[i]表示a[i]^a[i-1],e[i]=d[i]*igetd(x)和gete(x)分别表示对d/e求前x个元素的前缀xor用树状数组维护e[i]和d[i]的前缀xor区间更新[l,r],x:d[l]^=x,d[r+1]^=x,e[l]^=l*x,e[r+1]^=(r+1)*x区间查询a[x]的前缀xo…
problem Iahub and Xors 题目大意 一个n*n的矩阵,要求支持两种操作. 操作1:将一个子矩阵的所有值异或某个数. 操作2:询问某个子矩阵的所以值的异或和. 解题分析 由于异或的特殊性,可以用二维树状数组来维护. 因为同一个值只有异或奇数次才有效,因此若单点修改某个点,那么其影响的点为与其行和列奇偶性相同的点,故可以开4个二维树状数组来维护. 如果是区间修改x1,y1,x2,y2,则只需单点修改(x1,y1).(x1,y2+1).(x2+1,y2).(x2+1,y2+1) 如…
A. The Wall 求下gcd即可. B. Maximal Area Quadrilateral 枚举对角线,根据叉积判断顺.逆时针方向构成的最大面积. 由于点坐标绝对值不超过1000,用int比较快. C. Tourist Problem 假设序列为\(p_1,p_2,...,p_n\),则距离总和为\(,,,p_1,|p_2-p_1|,...,|p_n-p_{n-1}|\). 第1个点\(p_1\)的贡献为\(\sum a_i(n-1)!\) \(|p_i-p_{i-1}|\)的贡献为\…
C. Iahub and Permutations time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Iahub is so happy about inventing bubble sort graphs that he's staying all day long at the office and writing permu…
转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Iahub and Permutations Iahub is so happy about inventing bubble sort graphs that he's staying all day long at the office and writing permutations. Iahubina is angry that she is no more import…
F. Xors on Segments 题目连接: http://www.codeforces.com/contest/620/problem/F Description You are given an array with n integers ai and m queries. Each query is described by two integers (lj, rj). Let's define the function . The function is defined for o…