POJ2155 Matrix】的更多相关文章

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 up…
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…
题目链接 POJ2155 题解 二维线段树水题,蒟蒻本想拿来养生一下 数据结构真的是有毒啊,, TM这题卡常 动态开点线段树会TLE[也不知道为什么] 直接开个二维数组反倒能过 #include<algorithm> #include<iostream> #include<cstring> #include<cstdio> #include<cmath> #include<map> #define Redge(u) for (int…
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…
Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 17766   Accepted: 6674 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<math.h> #include<algorithm> #include<stdlib.h> using namespace std; #define ll long long #define re(i,n) for(int i=0;i<n;i++) ; int c[maxn][maxn]; int n, q; int lowbit(int x){ return x&…
题目: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]的和表示…
分析 好博客 区间修改,单点查询的题,可以用经典的树状数组的转化,把它化为单点修改,区间查询. 方法是在一些点上加1,最后查询单点的前缀和模2即为答案.相当于维护的是一个异或差分,利用了容斥. 可对查询的前缀矩阵对翻转矩阵的覆盖情况分类讨论须要在哪些点上加1. 最后发现若翻转子矩阵\((x_1,y_1)\rightarrow(x_2,y_2)\),只须在\((x_1,y_1),(x_1,y_2+1),(x_2+1,y_1),(x_2+1,y_2+1)\)这些点上加1,即可满足我们的需要. 代码…
关键词:线段树 二维线段树维护一个 维护一个X线段的线段树,每个X节点维护一个 维护一个Y线段的线段树. 注意,以下代码没有PushDownX.因为如果要这么做,PushDownX时,由于当前X节点的子节点可能存在标记,而标记不能叠加,导致每次PushDownX时都要把子节点PushDownX一次.每次PushDownX都要对子节点UpdateY,代价太高.这种情况下原则是:只有查询操作<<更新操作时才PushDownX. #include <cstdio> #include &l…