uva 11992】的更多相关文章

UVA 11992 - Fast Matrix Operations 题目链接 题意:给定一个矩阵,3种操作,在一个矩阵中加入值a,设置值a.查询和 思路:因为最多20列,所以全然能够当作20个线段树来做,然后线段树是区间改动区间查询,利用延迟操作,开两个延迟值一个存放set操作.一个存放add操作 代码: #include <cstdio> #include <cstring> #include <algorithm> using namespace std; #de…
UVA 11992 - Fast Matrix Operations 给定一个r*c(r<=20,r*c<=1e6)的矩阵,其元素都是0,现在对其子矩阵进行操作. 1 x1 y1 x2 y2 val 表示将(x1,y1,x2,y2)(x1<=x2,y1<=y2)子矩阵中的所有元素add上val: 2 x1 y1 x2 y2 val 表示将(x1,y1,x2,y2)(x1<=x2,y1<=y2)子矩阵中的所有元素set为val: 3 x1 y1 x2 y2 val 表示输…
题目链接 2015-10-30 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3143 给你一个矩阵,矩阵的每个元素初始值均为0 进行m次操作,操作共有三种类型,分别用1,2,3表示 操作一:子矩阵(x1, y1, x2, y2)的所有元素增加v 操作二:子矩阵(x1, y1, x2, y2)的所有元素设为v 操作三:查询子矩阵(x1,…
http://uva.onlinejudge.org/index.php? option=com_onlinejudge&Itemid=8&page=show_problem&problem=3143 矩阵变成一行,然后计算位置.lrj给了线段树数组做法 可是我做的线段树空间过大,直接爆掉,所以换方法了 主要还是測试自己的线段树区间更新的模板 各种RE+WA之后AC,,,,. 做的时候出现的几个错误: 1.行和列弄错 2.build初始化的时候,mmin mmax 都初始化为0才对…
题目传送门 题意:训练指南P207 分析:因为矩阵不超过20行,所以可以建20条线段的线段树,支持两个区间更新以及区间查询. #include <bits/stdc++.h> using namespace std; #define lson l, mid, o << 1 #define rson mid + 1, r, o << 1 | 1 typedef long long ll; const int INF = 0x3f3f3f3f; const int N =…
解法:因为至多20行,所以至多建20棵线段树,每行建一个.具体实现如下,有些复杂,慢慢看吧. #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using namespace std; #define N 1000010 struct node { int mini,maxi,sum; int addmark…
比较综合的一道题目. 二维的线段树,支持区间的add和set操作,然后询问子矩阵的sum,min,max 写完这道题也是醉醉哒,代码仓库里还有一份代码就是在query的过程中也pushdown向下传递标记. #include <cstdio> #include <cstring> #include <algorithm> using namespace std; << ; int _sum, _min, _max, op, x1, x2, y1, y2, x…
简单的线段树的题: 有两种方法写这个题,目前用的熟是这种慢点的: 不过不知道怎么老是T: 感觉网上A过的人的时间度都好小,但他们都是用数组实现的 难道是指针比数组慢? 好吧,以后多用数组写写吧! 超时的代码: #include<cstdio> #include<cstring> #include<algorithm> #define maxn 1000009 using namespace std; struct node { int l,r; int ma,mi,su…
input r c m      r<=20,1<=m<=20000 m行操作 1 x1 y1 x2 y2 v       add v 2 x1 y1 x2 y2 v       set v 3 x1 y1 x2 y2 查询该矩阵中的sum,max,min output 对于每个3操作输出sum,max,min 做法:每行建一颗线段树 #include <cstdio> #include <queue> #include <cstring> #incl…
线段树,注意tag优先级 #include<cstdio> #include<cstdlib> #include<algorithm> #include<cstring> #define MAXN 1000005 using namespace std; struct Node{ int sumv,maxv,minv,tag_add,tag_change; Node(,,,,){ sumv=p1,maxv=p3,minv=p2,tag_add=p4,tag_…