
字符串
文章平均质量分 67
algzjh
这个作者很懒,什么都没留下…
展开
-
2017湖南多校第一场-L(1011): Languages
LanguagesThe Enterprise has encountered a planet that at one point had been inhabited. The only remnant from the prior civilization is a set of texts that was found. Using a small set of keywords fou原创 2017-03-22 16:31:01 · 1393 阅读 · 0 评论 -
HDU6170-Two strings
Two stringsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 274 Accepted Submission(s): 90Problem Description Giving two strings and you sho原创 2017-08-22 20:00:12 · 1065 阅读 · 4 评论 -
KMP(非最大长度版本)
KMP模板:#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>using namespace std;int next[10];int nextval[10];void getnext(char *p,int next[]){ int plen=strlen(p); next[0]=原创 2017-02-08 11:49:01 · 498 阅读 · 0 评论 -
UVALive - 7043-International Collegiate Routing Contest
You may know that Bluegao University (formly Bluey University) is famous of networking technology. One day, their headmaster Yuege received a special router, along with a task about routing table. In原创 2019-03-28 15:18:46 · 436 阅读 · 0 评论 -
01串问题
链接:ARC088-D-Wide Flip 题目大意:给出一个长度为10510^5的01串,操作是每次选一个长度至少为KK的区间,将01反转,可进行多次操作,要使得最后为全0,问KK最大为多少。 解题思路: 对于字符串s[1…n]s[1 \dots n] 考虑相邻两位不同si≠si+1s_i \neq s_{i+1},要使得两位相同,最大可操作连续范围为max(i,n−i)max(i,n-i转载 2017-12-26 11:00:47 · 4458 阅读 · 0 评论 -
字符串的最小表示法
int n=strlen(s+1);for(int i=1;i<=n;i++) s[n+i]=s[i];int i=1,j=2,k;while(1<=n&&j<=n){ for(k=0;k<=n&&s[i+k]==s[j+k];k++); if(k==n) break;//s只由一个字符构成,形如"aaaaa" ...转载 2018-08-12 09:04:21 · 225 阅读 · 0 评论 -
扩展kmp
扩展KMP:能在O(|P|+|T|)O(|P|+|T|)\mathcal{O}(|P|+|T|)的时间复杂度内处理处字符串SSS的所有后缀与字符串TTT的最长公共前缀。 数组索引 0 1 2 3 4 5 6 7 8 字符串数组 a a a b a a a a b next数组 9 2 ...转载 2018-08-30 22:02:25 · 664 阅读 · 0 评论 -
字典树
const int MAX_N = 10000; // Trie 树上的最大结点数const int MAX_C = 26; // 每个结点的子结点个数上限struct Trie { int ch[MAX_N][MAX_C]; // ch 保存了每个结点的 26 个可能的子结点编号,26 对应着 26 种小写字母,也就是说,插入的字符串全部由小写字母组成。初始全部为 -1 ...转载 2018-08-30 22:30:40 · 181 阅读 · 0 评论 -
AC自动机
#include <iostream>#include <cstring>using namespace std;const int MAX_N=10000;const int MAX_C=26;struct AC_Automaton{ int ch[MAX_N][MAX_C],fail[MAX_N],cnt[MAX_N]; int tot;...转载 2018-08-31 10:33:20 · 161 阅读 · 0 评论 -
HDU2222-Keywords Search
Keywords SearchTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 65163 Accepted Submission(s): 21748Problem Description In the modern time,原创 2017-08-02 15:23:02 · 327 阅读 · 0 评论 -
Trie树
#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>using namespace std;const int maxnode=4000*100+10;const int MAXN=300;const int MAXM=1000;const int sigma_size=26;struct Tri原创 2017-07-31 17:07:48 · 230 阅读 · 0 评论 -
Codeforces798B-Mike and strings
B. Mike and stringstime limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Mike has n strings s1, s2, …, sn each consisting of lowercase English le原创 2017-04-22 07:16:03 · 876 阅读 · 0 评论 -
中南大学第十一届大学生程序设计竞赛-COJ1903-Tricky数
1903: Tricky数Submit Page Summary Time Limit: 1 Sec Memory Limit: 128 Mb Submitted: 11 Solved: 8 Description 小A很喜欢对着别人”233”,然后他发现有很多数字可以提取出他喜欢的233的子序列(一个数字由a[1,2,3…k]k个字符来表示,可以找到a[i原创 2017-04-27 11:14:18 · 573 阅读 · 0 评论 -
Horspool算法
Practical Fast Searching in StringsR. NIGEL HORSPOOLSchool of Computer Science, McGill University, 805 Sherbrooke Street West, Montreal, QuebecH3A 2K6, Canada原创 2017-05-18 15:52:34 · 1766 阅读 · 0 评论 -
Boyer-Moore算法
Algorithm Boyer-Moore第一步: 对于给定的模式和在模式及文本中用到的字母表,按照给出的描述构造坏符号移动表。 第二步: 按照之前给出的描述,利用模式来构造好后缀移动表。 第三步: 将模式与文本的开始处对齐。 第四步: 重复下面的过程,直到发现了一个匹配子串或者模式到达了文本的最后一个字符以外:从模式的最后一个字符开始,比较模式和文本中的相应字符,直到要么所有m个字符都匹配(原创 2017-05-18 16:36:02 · 960 阅读 · 1 评论 -
计蒜之道初赛第一场-阿里天池的新任务(简单)
阿里天池的新任务(简单)阿里“天池”竞赛平台近日推出了一个新的挑战任务:对于给定的一串 DNA 碱基序列 tt,判断它在另一个根据规则生成的 DNA 碱基序列 ss 中出现了多少次。首先,定义一个序列 ww:\displaystyle w_{i} = \begin{cases}b, & i = 0\\(w_{i-1} + a) \mod n, & i > 0\end原创 2017-05-20 22:30:31 · 566 阅读 · 0 评论 -
CodeForces 86C-Genetic engineering
Genetic engineering“Multidimensional spaces are completely out of style these days, unlike genetics problems” — thought physicist Woll and changed his subject of study to bioinformatics. Analysing resu原创 2019-03-28 15:19:26 · 936 阅读 · 1 评论 -
中南大学2016年校队选拔赛第一场Problem D
Problem D: 小X的标题Time Limit: 1 Sec Memory Limit:128 MBSubmit: 70 Solved: 10[Submit][Status][Ask]Description小X梦中得到一个神秘字符串,醒来后他赶快记了下来。这个字符串大概是一篇晦涩难懂的文章,姑且不用去管他的含义,小X想给它起一个标题来表示这份天书。但是原创 2016-08-23 20:34:25 · 822 阅读 · 0 评论 -
后缀数组
const int MAX_LEN = 200010;int r[MAXN]; // r 数组保存了字符串中的每个元素值,// 除最后一个元素外,每个元素的值在 1..m 之间,// 最后一个元素的值为 0int wa[MAXN], wb[MAXN], wv[MAXN], ws[MAXN]; // 这 4 个数组是后缀数组计算时的临时变量,无实际意义int sa[MAXN]; ...转载 2018-08-30 10:17:31 · 151 阅读 · 0 评论