![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
区间和
桃花仙人~
这个作者很懒,什么都没留下…
展开
-
单调栈问题
单调栈能够求得 该数左边离他最近的大于/小于的数(其他问题也可以转换为此问题)例如 求 a[i]左边第一个小于a[i]的数对于a[i]每次入栈如果有大于等于a[i]的数,直接出栈证明:如果求左侧第一个小于a[i]的数如果a[i]入栈后左侧有大于a[i]的数,则那个数不仅是大值而且还出现的比较早,所以他永远不会被用到,所以直接出栈单调栈板子#include<iostream>#include<cstdio>#include<cstring>...原创 2020-12-03 21:11:13 · 189 阅读 · 0 评论 -
差分矩阵
差分矩阵#include<iostream>using namespace std;const int N=1e3+10;int st[N][N],a[N][N];void insert(int i,int j,int x,int y,int c){ st[i][j]+=c; st[i][y+1]-=c; st[x+1][j]-=c; st[x+1][y+1]+=c;}int main(){ ios::sync_with_stdio(原创 2020-10-13 19:20:19 · 148 阅读 · 1 评论 -
树状数组+线段树
树状数组,线段树都是单点修改,区间查询如果树状数组想要区间修改可以弄成差分数组树状数组+差分一道例题树状数组写法#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;const int N = 100010;int n, m;int a[N], tr[N];int lowbit(int原创 2020-09-16 19:51:14 · 95 阅读 · 0 评论