随笔 - 530
文章 - 0
评论 - 3
阅读 -
10098
随笔分类 - 字符串
manacher 记录
摘要:首先注意 2* n 的长度 mx: 当前匹配到的最大长度 即 [1,mx] id: mx 对应的中心点 pi : s[i] 为中心的回文串的最大长度, pi /2 -1 是半径() #include <iostream> #include <cstring> #include <algorithm>
阅读全文
P4551 最长异或路径
摘要:给定一棵 nn 个点的带权树,结点下标从 11 开始到 nn。寻找树中找两个结点,求最长的异或路径。 异或路径指的是指两个结点之间唯一路径上的所有边权的异或。 处理出每个点的树上异或前缀 这些异或值按照二进制数插入Trie 经典问题了 #include <iostream> #include <cs
阅读全文
P3879 [TJOI2010] 阅读理解
摘要:查找单词个数 样例: 3 9 you are a good boy ha ha o yeah 13 o my god you like bleach naruto one piece and so do i 11 but i do not think you will get all the poi
阅读全文
P2375 [NOI2014] 动物园
摘要:求num[i] ,表示1~i前缀 的合法子串个数( 满足前后缀相等,且不重合 #include <iostream> #include <cstring> using namespace std; const int N =1e6+3 ,mod= 1e9+7; #define int long lo
阅读全文
P4824 [USACO15FEB] Censoring S
摘要:希望在Str 中删掉 1个屏蔽词(一个屏蔽词可能出现多次) 求最后的串 栈+hash #include <iostream> #include <cstring> using namespace std; const int N =1e6+3; #define int long long int b
阅读全文
P3435 [POI2006] OKR-Periods of Words
摘要:对于给定串的每个前缀i,求最长的,使 这个字符串重复两边能覆盖原前缀i的前缀(就是前缀i的一个前缀),求所有的这些“前缀的前缀”的长度和 一张图秒懂 求next[] , 对于前缀i ,设 j =next[i] , 他有一个周期 i- j #include <bits/stdc++.h> using
阅读全文
#10051. 「一本通 2.3 例 3」Nikitosh 和异或
摘要:求两段不相交子序列,他们异或和的 和最大 #include<iostream> #include <algorithm> #include <cstring> using namespace std; const int N =4e5+4; int ch[N*32][2],ans; int tot=
阅读全文
The XOR Largest Pair
摘要:从序列A中选出两个进行异或运算,得到的结果最大是多少? 两个数二进制插入Trie 每次遍历时尽量走反 #include<iostream> #include <algorithm> #include <cstring> using namespace std; const int N =1e5+4;
阅读全文
Shortest Prefixes POJ - 2001
摘要:给一些串,问每个串的唯一前缀,若不存在输出本身 #include<iostream> #include <cstring> #include <algorithm> using namespace std ; const int N =1e5; int ch[N][30],tot,val[N]; v
阅读全文
1471:【例题1】Phone List
摘要:给一些字符串 , 问 是否有两个串有前缀关系 字典树节点维护结束标记 val[ ] , 跑的时候检查一下 #include<iostream> #include <algorithm> #include <cstring> using namespace std; const int N=1e5+4
阅读全文
Problem C HDU - 5687
摘要:现在有个字典要支持一下操作 1、insert : 往神奇字典中插入一个单词 2、delete: 在神奇字典中删除所有前缀等于给定字符串的单词 3、search: 查询是否在神奇字典中有一个字符串的前缀等于给定的字符串 字典树每个节点维护 sum[ i ] delete 操作: 先查询包含该串的串个数
阅读全文
统计难题 HDU - 1251
摘要:给一些字符串,问以某个串为前缀的串有几个 #include<iostream> #include <algorithm> #include <cstring> using namespace std; const int N=5e5+4; char num[80]; int len,sum[N];
阅读全文
n^2 判断回文串
摘要:int test(int a,int b){ if(a>=b) return 1; if(s[a]!=s[b]) return 0; if(vis[a][b]) return pal[a][b]; vis[a][b]=1; return pal[a][b]=test(a+1,b-1); }
阅读全文
字符串 记录2
摘要:http://ybt.ssoier.cn:8088/problem_show.php?pid=1471 字典树板子 http://ybt.ssoier.cn:8088/problem_show.php?pid=1472 "异或",都每个数,在树上每次贪心地走相反地路径 https://loj.ac/
阅读全文
字符串 记录
摘要:https://vjudge.net/problem/HDU-3336 http://ybt.ssoier.cn:8088/problem_show.php?pid=1455 给出两个字符串S,T, 求 T在S中出现多少次 hash或kmp http://ybt.ssoier.cn:8088/pro
阅读全文
acwing 140. 后缀数组
摘要:把字符串S的所有后缀按照字典序排列,排名为 i 的后缀记为SA[ i ] 额外地,我们考虑排名为 i 的后缀与排名为 i-1 的后缀,把二者的最长公共前缀的长度记为 hgt[i] 使用快排、Hash 与二分 求出 两个数组 #include<iostream> #include <algorithm
阅读全文
acwing 139. 回文子串的最大长度
摘要:枚举回文串的中心点 ,二分左右的长度 判断两个字符串时用hash #include<iostream> #include <algorithm> #include <cstring> using namespace std; #define ll unsigned long long const i
阅读全文
kmp板子
摘要:主串a,模式串b,求b在a中出现的位置 #include<algorithm> #include<iostream> #include<cstring> #include<cstdio> #include<cmath> using namespace std; const int N = 1e6+3
阅读全文
loj#103 字符串hash板子
摘要:在串A中找B,输出B出现的次数 rt 这是字符串hash板子 #include<iostream> #include <algorithm> #include <cstring> using namespace std; #define int long long const int N=1e6+5
阅读全文
一本通 1479 AC自动机板子
摘要:kmp+字典树 #include <iostream> #include <cstring> #include <queue> using namespace std ; const int N=1e4+2,M=1e6+2; char s[M]; int val[N]; int ch[N][30],
阅读全文