poj2155一个二维树状数组】的更多相关文章

                                                                                                               Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 15125   Accepted: 5683 Description Given an N*N matrix A, whose element…
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…
这题反反复复,到现在才过. 这道题就是树状数组的逆用,用于修改区间内容,查询点的值. 如果单纯就这个奇偶数来判的话,似乎这个思路比较好理解. 看了一下国家集训队论文(囧),<关于0与1在信息学奥赛中的运用>,. 还有这题卡在输入输出好久. update(a,b,1); update(a,d,-1); update(c,b,-1); update(c,d,1);  用来判二维的情况!! #include <iostream> #include <stdio.h> #inc…
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…
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…
这道题是一个二维树状数组,思路十分神奇,其实还是挺水的 题目描述 给定一个N∗NN∗N的矩阵AA,其中矩阵中的元素只有0或者1,其中A[i,j]A[i,j]表示矩阵的第i行和第j列(1≤i,j≤N)(1≤i,j≤N),初始矩阵元素都是0.在矩阵上进行TT次操作,操作有以下两种: (1)格式为C x1 y1 x2 y2(1≤x1≤x2≤n,1≤y1≤y2≤n)C x1 y1 x2 y2(1≤x1≤x2≤n,1≤y1≤y2≤n) ,其中CC为字符"C",表示把以(x1,y1)(x1,y1)…
链接:https://www.lydsy.com/JudgeOnline/problem.php?id=1452 思路: 对每个颜色开一个二维树状数组维护就好了 实现代码: #include<bits/stdc++.h> using namespace std; ][][]; ][],n,m,q; int lowbit(int x){ return x&-x; } void add(int x,int y,int z,int rt){ for(int i = x;i <= n;i…
时间限制: 1 Sec 内存限制: 128 MB 题目描述 一个n*m的方格,初始时每个格子有一个整数权值.接下来每次有2种操作: 改变一个格子的权值: 求一个子矩阵中某种特定权值出现的个数. 输入 第一行有两个数n,m. 接下来n行,每行m个数,第i+1行第j个数表示格子(i,j)的初始权值. 接下来输入一个整数q. 接下来q行,每行描述一个操作. 操作1:“1 x y c”(不含双引号).表示将格子(x,y)的权值改成c(1<=x<=n,1<=y<=m,1<=c<=…
对每种颜色开一个二维树状数组 #include<cstdio> #include<algorithm> using namespace std; ; ][maxn][maxn],c[maxn][maxn],Q,n,m,k,x,y,xx,yy,col; inline void read(int &k){ k=; ; char c=getchar(); ),c=getchar(); +c-',c=getchar(); k*=f; } inline void add(int co…
题目:http://poj.org/problem?id=2155 中文题意: 给你一个初始全部为0的n*n矩阵,有如下操作 1.C x1 y1 x2 y2 把矩形(x1,y1,x2,y2)上的数全部取反,1->0,0->1 2.Q x y 求n*n矩阵的(x,y)位置上的数 题解: 先看简单的: 给你一个初始全为0的长度为n的序列,有如下操作 1.C x y 把序列x到y位取反1->0,0->1 2.Q x 求序列第x位的数 做法很简单,设计一个数组a[],a[1..i]的和表示…