POJ 2155 Matrix (2维树状数组)】的更多相关文章

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…
题意:给你一个矩阵开始全是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…
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…
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…
思路: 大力出奇迹,先用二维树状数组存,然后暴力枚举 算某个矩形区域的值的示意图如下,代码在下面慢慢找... 代码: #include<cstdio> #include<map> #include<cstring> #include<algorithm> #define ll long long using namespace std; const int N = 1030+5; int bit[N][N],n,m; int lowbit(int x){ r…
题目链接: https://vjudge.net/problem/SPOJ-MATSUM 题目大意: 二维数组,两种操作 SET 将某点设置成x SUM 求某个区域之和 解题思路: 这里用二维树状数组 SUM可以直接求出来 这里将某点设置成x,和树状数组不同,树状数组是讲某点加上一个值,但是可以另外建一个数组存储当前所有点的数值,如果要将(x, y)设置成d的话,可以先把该点减去a[x][y]再加上d 合并一下就是:add(x, y, d - a[x][y]) #include<iostream…
Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 16950   Accepted: 6369 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…
#include<iostream> #include<string> #include<string.h> #include<cstdio> using namespace std; ; int n; int c[maxn][maxn]; int lowbit(int x) { return x&(-x); } void update(int x,int y) { for(int i = x; i; i -= lowbit(i)) for(int…
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 up…