题目链接:点击打开链接
题意:
rt。。
在询问时,两端向上爬时记录从深度浅的到深度深的方向上的 (也就是左最大连续子段和)
最后两个点在同一条重链上时合并。
合并时要注意有4种情况, 详见代码。
线段树部分和5相似。
#include <cstdio>
#include <iostream>
#include <string.h>
#include <vector>
using namespace std;
inline void rd(int &n){
n = 0;
bool tmp = 0;
char c = getchar();
while((c < '0' || c > '9') && c != '-' ) c = getchar();
if(c == '-') c = getchar(), tmp = 1;
while(c >= '0' && c <= '9') n *= 10, n += (c - '0'),c = getchar();
if(tmp) n = -n;
}
#define N 100100
#define hehe 10001
#define L(x) tree[x].l
#define R(x) tree[x].r
#define Lson(x) (x<<1)
#define Rson(x) (x<<1|1)
#define Sum(x) tree[x].sum
#define Max(x) tree[x].max
#define Lmax(x) tree[x].lmax
#define Rmax(x) tree[x].rmax
#define Lazy(x) tree[x].lazy
#define Siz(x) tree[x].siz()
struct node{
int l, r;
int mid(){return (l+r)>>1;}
int siz(){return r-l+1;}
int lmax, rmax, max, sum, lazy;
}tree[N<<2];
int n, a[N], Q, fw[N];
void updata_point(int val, int id){Lmax(id) = Rmax(id) = Max(id) = Sum(id) = val * Siz(id);}
void push_down(int id){
if(L(id) == R(id))retur