随笔分类 -  线段树

摘要:题面:洛谷传送门 ####题目的算法要素:线段树&返回值为结构体的线段树 ####题目分析: 线段树的单点赋值+区间查询(查询区间内和最大的一段序列)。 因为某一段区间内和最大的一段序列是从它的小区间中合并出来的,需要不断与其他区间比较,且小区间内的最大序列不一定是大区间内的最大序列的一部分。 因此 阅读全文
posted @ 2021-09-16 17:28 Mint-hexagram 阅读(25) 评论(0) 推荐(0)
摘要:一道特别水的线段树基础题。 不过发生了一些有意思的事情: 我最开始没算复杂度,就直接去想怎么对区间取模操作写懒标记和pushdown。 其实因为取模不会进行太多次,而且在中间可以特判结束向下递归,因此直接单点修改即可。 #include<bits/stdc++.h> using namespace 阅读全文
posted @ 2021-09-15 07:55 Mint-hexagram 阅读(88) 评论(0) 推荐(0)
摘要:#include<bits/stdc++.h> using namespace std; const int N=2e5+10; int n,m,q,tot=0; int a[N],b[N]; int T[N],sum[N<<5],L[N<<5],R[N<<5]; int build(int l,i 阅读全文
posted @ 2021-08-26 15:48 Mint-hexagram 阅读(46) 评论(0) 推荐(0)
摘要:#include<cstdio> using namespace std; int const maxn = 1e6; int n, m; long long sum[4 * maxn + 5], input[maxn+5], add[maxn * 4 + 5]; inline void build 阅读全文
posted @ 2021-06-24 21:00 Mint-hexagram 阅读(38) 评论(0) 推荐(0)