[NOI2003]文本编辑器 没啥好说的 就是个板子 #include <bits/stdc++.h> // #define int long long #define rep(a , b , c) for(int a = b ; a <= c ; ++ a) #define Rep(a , b , c) for(int a = b ; a >= c ; -- a) #define go(u) for(int i = G.head[u] , v = G.to[i] , w = G.…
题面 洛谷 题解 首先,我们知道求最长公共前缀可以用二分答案+hash来求 因为有修改操作, 考虑将整个字符串的hash值放入splay中 接着就是splay的基本操作了 Code #include<bits/stdc++.h> #define LL long long #define RG register const int N = 500010; typedef unsigned long long ull; using namespace std; inline int gi() {…
https://www.luogu.org/problem/P4008 无旋Treap也可以维护序列. 千万要注意要先判断p节点存在才进行Show操作,不然输出一个'\0'(或者RecBin里面的东西)草. 假如有限制同时存在的节点数量的话,UnBuild操作是显得重要的. 当然这里最主要的是类似笛卡尔树的O(n)建立Treap树. #include<bits/stdc++.h> using namespace std; typedef long long ll; #define ls(p)…
题目链接 第一次写(2017.11.7): #include<cstdio> #include<cctype> using namespace std; const int N=1e5+5,INF=1e9; int size,root,t[N],sz[N],son[N][2],fa[N],cnt[N]; inline int read() { int now=0,f=1;register char c=getchar(); for(;!isdigit(c);c=getchar())…
题目链接 //模板吧 #include<cstdio> #include<cctype> #include<algorithm> using namespace std; const int N=40000,INF=1e8; int n,size,root,sz[N],cnt[N],t[N],son[N][2],fa[N]; inline int read() { int now=0,f=1;register char c=getchar(); for(;!isdigi…
题意 splay维护即可 code: #include<bits/stdc++.h> using namespace std; const int maxn=2000010; int T,tot,points,root; int fa[maxn],size[maxn]; int ch[maxn][2]; char str[maxn],s[maxn]; queue<int>pool; inline int read() { char c=getchar();int res=0,f=1…