题意:Given n integers.
You have two operations: U A B: replace the Ath number by B. (index counting from 0) Q A B: output the length of the longest consecutive increasing subsequence (LCIS) in [a, b].分析:区间合并类线段树。
las[maxn<<2] 区间左端起最长的序列长度
ras[maxn<<2] 区间右端起最长的序列长度 mov[maxn<<2] 区间最优值#include#include #include #define maxn 100005#define clr(x)memset(x,0,sizeof(x))int max(int a,int b){ return a>b?a:b;}int min(int a,int b){ return a >1; creat(l,mid,rt<<1); creat(mid+1,r,rt<<1|1); pushup(l,r,mid,rt);}void update(int pos,int val,int l,int r,int rt){ if(l==r) { va[l]=val; return; } int mid=(l+r)>>1; if(pos<=mid) update(pos,val,l,mid,rt<<1); else update(pos,val,mid+1,r,rt<<1|1); pushup(l,r,mid,rt);}int query(int L,int R,int l,int r,int rt){ if(L<=l&&r<=R) return mov[rt]; int mid=(l+r)>>1; int res=0; if(R <= mid) return query(L,R,l,mid,rt<<1); else if(L>mid) return query(L,R,mid+1,r,rt<<1|1); else { int tmp=0; if(va[mid]