Description Given an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the i-th row and j-th column. Initially we have A[i, j] = 0 (1 <= i, j <= N). We can change the matrix in the following way. Given a rectangle whose upp…
Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 20599   Accepted: 7673 Description Given an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the i-th row and j-th column. Initially we have A[i, j] = 0 (1…
题目链接: https://vjudge.net/problem/POJ-2155 题目大意: 给一个n*n的01矩阵,然后有两种操作(m次)C x1 y1 x2 y2是把这个小矩形内所有数字异或一遍,Q x y 是询问当前这个点的值是多少?n<=1000 m<=50000. 解题思路: 裸的二维树状数组,但是这里是区域更新,单点查询, 做法应该是 #include<cstdio> #include<cstring> #include<iostream> #…
题意:给你一个矩阵开始全是0,然后给你两种指令,第一种:C x1,y1,x2,y2 就是将左上角为x1,y1,右下角为x2,y2,的这个矩阵内的数字全部翻转,0变1,1变0 第二种:Q x1 y1,输出举证x1,y1,位置的数值 思路:该题的巧妙之处是反转的重叠抵消,记住要向上统计,向下修改:二维情况,最主要的是理解那个数组中的每个点保存的值的意义(一个矩形区域的总和):最后记住取余: 此题参考博客 http://blog.csdn.net/xymscau/article/details/660…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3584 题目大意: 给定一个N*N*N多维数据集A,其元素是0或是1.A[i,j,k]表示集合中第 i 行,第 j 列与第 k 层的值. 首先由A[i,j,k] = 0(1 <= i,j,k <= N). 给定两个操作: 1:改变A[i,j,k]为!A[i,j,k]. 2:查询A[i,j,k]的值. 解题思路: 三维树状数组模拟,利用容斥原理 #include<cstdio> #inc…
题意:给你一个n*n的全0矩阵,每次有两个操作: C x1 y1 x2 y2:将(x1,y1)到(x2,y2)的矩阵全部值求反 Q x y:求出(x,y)位置的值 树状数组标准是求单点更新区间求和,但是我们处理一下就可以完美解决此问题.区间更新可以使用区间求和的方法,在更新的(x2,y2)记录+1,在更新的(x1-1,y1-1)-1(向前更新到最前方).单点求和就只需要与区间更新相反,向后求一个区间和.这样做的理由是:如果求和的点在某次更新范围内,我们+1但是不执行-1,否者要么都不执行,要么都…
Given an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the i-th row and j-th column. Initially we have A[i, j] = 0 (1 <= i, j <= N). We can change the matrix in the following way. Given a rectangle whose upper-left corn…
开心.jpg J.farm 先解释一下题意,题意就是一个n*m的矩形区域,每个点代表一个植物,然后不同的植物对应不同的适合的肥料k,如果植物被撒上不适合的肥料就会死掉.然后题目将每个点适合的肥料种类(不同的数字代表不同的种类)给出(最多n*m种肥料),然后T次操作,每次操作都是把以(x1,y1)为左上角,以(x2,y2)为右下角确定的矩形区域撒上种类为k的肥料,问T次操作后,死掉了多少植物. 这个题可以是个经典的二维树状数组的题目,通过二维树状数组维护区间,以及各种神奇操作过了这道题. 这道题有…
Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 21757   Accepted: 8141 Description Given an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the i-th row and j-th column. Initially we have A[i, j] = 0 (1…
Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 25004   Accepted: 9261 Description Given an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the i-th row and j-th column. Initially we have A[i, j] = 0 (1…