我不会告诉你这是线段树合并的好题的... 好吧我们可以搞一个multiset在dfs时求出LIS(自带二分+排序)进行启发式合并,轻松加愉悦... #include<cstdio> #include<iostream> #include<set> ; #define R register int using namespace std; inline int g() { R ret=; register char ch; while(!isdigit(ch=getcha…
F[x][i]表示x的子树中取的数字<=i的最大值,线段树合并优化DP 写得很难看,并不知道好看的写法 #include<cstdio> #include<algorithm> using namespace std; int cnt,n,Num,ans,last[200005],tag[10000005],ls[10000005],rs[13000005],E[200005],a[200005],Fa[200005],root[200005],ANS[200005],tre…
传送门 启发式合并菜题. 题意:支持与连通块有关的几种操作. 要求支持连边,单点修改,连通块修改,全局修改和单点查值,连通块查最大值和全局最大值. 我们对每个连通块和答案用可删堆维护最大值,然后用启发式合并来解决连边的问题. 关键在于连通块修改,这个可以给每个连通块维护一个标记,然后在合并的时候每个数记得修改值就行了. 代码 #include<bits/stdc++.h> #define ri register int using namespace std; inline int read(…