fhq treap+启发式合并,将小的合并到大的上面,复杂度NlogN. 最好的一点是通过dfs将一个子树内的元素转到另一个元素上. By:大奕哥 #include<bits/stdc++.h> using namespace std; ; int n,m,f[N],a[N],ma[N]; struct node { int l,r,s,rnd,v; }t[N]; int get(int x){return f[x]==x?x:f[x]=get(f[x]);} ;} void split(in…