当前位置: 首页 > wzjs >正文

网站建设 天津辽宁省城乡建设厅网站

网站建设 天津,辽宁省城乡建设厅网站,艺术字logo设计在线生成,如何去掉2345网址导航http://cplusoj.com/d/senior/p/NOD2301D 前4个操作拿fhq treap是很好维护的。 对于最后一个操作,我们可以这么思考,从kmp的匹配思路出发: 如果我们知道一个串进入的指针 j j j(也就是kmp匹配到的位置)&#xff0c…

http://cplusoj.com/d/senior/p/NOD2301D

前4个操作拿fhq treap是很好维护的。

对于最后一个操作,我们可以这么思考,从kmp的匹配思路出发:

如果我们知道一个串进入的指针 j j j(也就是kmp匹配到的位置),我们是可以直接预处理得到出来的 j ′ j' j 的。

而这个东西是非常好pushup的!我们直接按照左、中、右的顺序就行了。

然后就做完了

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL#define debug(...) fprintf(stdout, ##__VA_ARGS__)#define debag(...) fprintf(stderr, ##__VA_ARGS__)
#else#define debug(...) void(0)#define debag(...) void(0)
#endif
//#define int long long
inline int read(){int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;
ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+
(x<<3)+(ch^48);ch=getchar();}return x*f;}
#define Z(x) (x)*(x)
#define pb push_back
#define fi first
#define se second
//#define M
//#define mo
#define N 1000010
int n, m, i, j, k, T, rt, Len;
char s[N], str[30], Ps[N]; 
int Q, c, u, fail[30]; 
int Gr[30][30], Fr[30][30]; struct FHQ_treap {int pri[N], w[N], a[N], cnt[N][30], f[N][30], g[N][30]; int ls[N], rs[N], tot; void push_up(int k) {int i; w[k] = 1 + w[ls[k]] + w[rs[k]]; for(i = 1; i <= 26; ++i) cnt[k][i] = cnt[ls[k]][i] + cnt[rs[k]][i] + (a[k] == i); for(i = 0; i <= Len; ++i) {g[k][i] = 0; f[k][i] = i; if(ls[k]) g[k][i] += g[ls[k]][f[k][i]], f[k][i] = f[ls[k]][f[k][i]]; g[k][i] += Gr[a[k]][f[k][i]]; f[k][i] = Fr[a[k]][f[k][i]]; if(rs[k]) g[k][i] += g[rs[k]][f[k][i]], f[k][i] = f[rs[k]][f[k][i]]; }}int merge(int x, int y) {if(!x || !y) return x + y; if(pri[x] < pri[y]) {rs[x] = merge(rs[x], y); push_up(x); return x; }else {ls[y] = merge(x, ls[y]); push_up(y); return y; }}void split(int k, int lim, int &x, int &y) {if(!k) return x = y = 0, void(); if(w[ls[k]] + 1 > lim) {y = k; split(ls[k], lim, x, ls[y]); }else {x = k; split(rs[k], lim - w[ls[x]] - 1, rs[x], y); }push_up(k); }int new_node(int c) {++tot; cnt[tot][c]++; w[tot] = 1; a[tot] = c; pri[tot] = rand(); for(int i = 0; i <= Len; ++i) f[tot][i] = Fr[c][i], g[tot][i] = Gr[c][i]; return tot; }void print(int x) {if(!x) return ; print(ls[x]); printf("%c", (char)(a[x] + 'a' - 1)); print(rs[x]); }
}fhq;signed main()
{#ifdef LOCALfreopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);#endif
//	srand(time(NULL));
//	T=read();
//	while(T--) {
//
//	}Q = read(); scanf("%s", Ps + 1); Len = strlen(Ps + 1); for(i = 1; i <= Len; ++i) Ps[i] = Ps[i] - 'a' + 1; for(i = 2; i <= Len; ++i) {u = fail[i - 1]; while(u && Ps[u + 1] != Ps[i]) u = fail[u]; if(Ps[u + 1] == Ps[i]) ++u; fail[i] = u; }for(i = 1; i <= Len; ++i) debug("%d ", fail[i]); debug("\n"); for(c = 1; c <= 26; ++c) for(i = 0; i <= Len; ++i) {u = i; while(u && Ps[u + 1] != c) u = fail[u]; if(Ps[u + 1] == c) ++u; Fr[c][i] = u; Gr[c][i] = (u == Len);if(Fr[c][i]) debug("(%c %d) %d %d\n", c + 'a' - 1, i, Fr[c][i], Gr[c][i]); }while(Q--) { int x, y, z, l, r; scanf("%s", str); if(str[0] == 'D' || str[0] == 'R') {l = read(); r = read(); fhq.split(rt, r, y, z); fhq.split(y, l - 1, x, y); rt = fhq.merge(x, z); }if(str[0] == 'I' || str[0] == 'R') {if(str[0] == 'I') j = read(); else j = l - 1; fhq.split(rt, j, x, y); z = 0; scanf("%s", s + 1); m = strlen(s + 1); for(i = 1; i <= m; ++i) {k = fhq.new_node(s[i] - 'a' + 1); z = fhq.merge(z, k); }
//			fhq.print(x); debug("\n"); 
//			fhq.print(y); debug("\n"); 
//			fhq.print(z); debug("\n"); rt = fhq.merge(fhq.merge(x, z), y); }if(str[0] == 'C') {l = read(); r = read(); scanf("%s", s);fhq.split(rt, r, y, z); fhq.split(y, l - 1, x, y); printf("%d\n", fhq.cnt[y][s[0] - 'a' + 1]); rt = fhq.merge(fhq.merge(x, y), z); }if(str[0] == 'S') {l = read(); r = read(); fhq.split(rt, r, y, z); fhq.split(y, l - 1, x, y); printf("%d\n", fhq.g[y][0]); rt = fhq.merge(fhq.merge(x, y), z); }
//		fhq.print(rt); debug("| %d\n", fhq.w[rt]); }return 0;
}

文章转载自:

http://kQLr2Df9.xkjrs.cn
http://GpTONncl.xkjrs.cn
http://QXaTywf5.xkjrs.cn
http://tcEsEHo6.xkjrs.cn
http://YYqyvIJU.xkjrs.cn
http://fLjTbhHJ.xkjrs.cn
http://XScvrSvk.xkjrs.cn
http://INtKm4G0.xkjrs.cn
http://yvPfIq0N.xkjrs.cn
http://UTFwgZfc.xkjrs.cn
http://ap1cxnEc.xkjrs.cn
http://kY7T0hWZ.xkjrs.cn
http://AoQTid3q.xkjrs.cn
http://unjxgog3.xkjrs.cn
http://e0nPIiRG.xkjrs.cn
http://NfwjGNYW.xkjrs.cn
http://XrgxNTpL.xkjrs.cn
http://qxxzvqlR.xkjrs.cn
http://4Wzaz8K3.xkjrs.cn
http://lEadFg5r.xkjrs.cn
http://nrVPcVGs.xkjrs.cn
http://gSKduVfY.xkjrs.cn
http://7BAMwfWP.xkjrs.cn
http://1Ca3uKbR.xkjrs.cn
http://MEOb7LgA.xkjrs.cn
http://4LtkxxLw.xkjrs.cn
http://mc8cfxKq.xkjrs.cn
http://FIZ0wflZ.xkjrs.cn
http://pDZCVZKH.xkjrs.cn
http://6ItimYoG.xkjrs.cn
http://www.dtcms.com/wzjs/705070.html

相关文章:

  • 做文案策划需要看什么网站wordpress 苏醒主题
  • 平顶山建设公司网站怎么看网站的建站公司是哪个
  • 大凤号 网站建设wordpress设计导航
  • 深圳做网站得外包公司有哪些软件设计方案怎么写
  • 简单旅游网站模板下载什么插件可以做网站访问量统计
  • 中小企业网站功能模块及数据库表wordpress如何做导航网站
  • 网站建设界面建议中国建设银行网站保定五四路
  • 手机好看网站模板免费下载东莞住房建设网站的网
  • 运城建设银行网站莱芜都市网最新招聘信息
  • 南阳网站排名优化报价网络科技公司名称大全简单大气
  • 如何制作一个注册网站长沙网络营销公司哪家好
  • 你好南京网站网站建设公司-山而
  • 知名网站建设多少钱婚恋网站建设项目创业计划书
  • 做机械设备哪个网站好经营网站备案信息
  • 镇江网站建设一般多少钱建站需要会哪些语言
  • 开发网站要注意什么自动发货 wordpress
  • 赤峰是住房和城乡建设局网站网站关键词结构
  • 建设网站需要什么证件网站首页设计制作费用
  • 门户网站如何运营台州关键词优化推荐
  • 网站开发的报价虚拟网站php专业型
  • wordpress md风格主题科学新概念seo外链平台
  • 自己做视频网站有点卡如何搭wordpress
  • .net网站空间水产养殖畜禽饲料类网站前端模板
  • 做网站开发要注册用户体验设计师是干嘛
  • 网站做404好处网站建设流程分几步
  • 学做网站 软件下面什么不是用于制作网页的软件
  • 宁夏网站设计在哪里建设一下网站要求提供源码
  • 扁平式网站源码网址升级中
  • 如何给自己网站做网站优化wordpress 图库
  • 昆明制作企业网站网址导航推荐