这个题目意思很简单,就是求连续的最长段。
查询次数比较多,时间卡的比较紧
之前写了个k*logn*logn的,结果tle了,pushup的时候如果每次都修改到满节点时pushup的话,因为一个区间最多被分成logn次,加上每次pushup最多执行logn次操作,所以复杂度就高了
其实更简单一点的方法是当修改了一个节点的局部时,就重新修改该节点的值。这样复杂度就变低了,这样看起来,真的还是得多思考,线段树貌似多种修改都是采取后面的方法会快得多。
讲讲具体思路: 非常简单,lamx,rmax,max分别表示左连续最大,右连续最大,连续最大。
#include <iostream>
#include <stdio.h>
#include <string.h>
#define ls t<<1
#define rs t<<1|1
#define midt(tr[t].l+tr[t].r)>>1
using namespace std;
const int maxn=16000+10;
struct
{
}tr[maxn*4];
inline int max(int a,int b)
{
}
int maketree(int t,int l,int r)
{
}
void pushdown(int t)
{
}
void modify(int t,int l,int r,int tmp)
{
}
int main()
{
}