
字符串类问题
winycg
问题可联系QQ:1241981936
展开
-
hdu1251 统计难题 字典树插入,查询模板和空间释放
字典树插入,查询模板和空间释放 #include #include #include using namespace std; struct trienode { int ncount;//该节点前缀 出现的次数 struct trienode *next[26+5];//该节点的后续节点 }; void inserttrie(struct trienode* &t,string原创 2016-03-08 18:37:30 · 568 阅读 · 0 评论 -
Manacher算法求最长回文子串
解释转载为此博客:https://www.felix021.com/blog/read.php?2040 下面以字符串12212321为例,经过上一步,变成了 S[] = "$#1#2#2#1#2#3#2#1#"; 然后用一个数组 P[i] 来记录以字符S[i]为中心的最长回文子串向左/右扩张的长度(包括S[i],也就是把该回文串“对折”以后的长度),比如S和P的对应关系: S #转载 2017-04-13 13:49:57 · 296 阅读 · 0 评论 -
hdu1711 Number Sequence 求模式串在主串中的位置
Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], ...... , b[M] (1 <= M <= 10000, 1 <= N <= 1000000). Your task is to find a number K which make a[K] = b[1], a[K + 1] = b[2],原创 2016-03-22 16:16:19 · 484 阅读 · 0 评论 -
hdu 2087 剪花布条 求模式串在主串中的个数
Problem Description 一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案。对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出几块小饰条来呢? Input 输入中含有一些数据,分别是成对出现的花布条和小饰条,其布条都是用可见ASCII字符表示的,可见的ASCII字符有多少个,布条的花纹也有多少种花样。花纹条和小饰条不会超过1000个字符长。原创 2016-03-22 16:18:19 · 438 阅读 · 0 评论 -
KMP算法中怎么求next数组
例如: 1 2 3 4 5 6 7 8 模式串 a b a a b c a c next值 0 1 1 2 2 3 1 2 next数组的求解方法是:第一位的next值为0,第二位的next值为1,后面求解每一位的next值时,根据前一位进行比较。首先将前一位与其next值对应的内容进行比较,如果相等原创 2016-08-02 20:00:23 · 1136 阅读 · 0 评论 -
KMP的应用
利用next数组求字符串的最小周期 结论:如果有一个字符串s,长度是len,它的失败函数是next,如果len能被len-next[len]整除,那么len-next[len]就是我们要求的那个子串的长度,与之对应的字符串,就是我们想得到的子串; poj 1961 #include #include #include #include #include #include #include原创 2016-08-02 20:11:13 · 368 阅读 · 0 评论 -
CCF 模板生成系统 字符串string函数find的使用
问题描述 成成最近在搭建一个网站,其中一些页面的部分内容来自数据库中不同的数据记录,但是页面的基本结构是相同的。例如,对于展示用户信息的页面,当用户为 Tom 时,网页的源代码是 而当用户为 Jerry 时,网页的源代码是 这样的例子在包含动态内容的网站中还有很多。为了简化生成网页的工作,成成觉得他需要引入一套模板生成系统。 模板是包含特殊标记的文本。成原创 2017-03-12 22:24:20 · 841 阅读 · 0 评论 -
hdu 4691后缀数组+RMQ----子字符串的最长公共前缀
Description Front compression is a type of delta encoding compression algorithm whereby common prefixes and their lengths are recorded so that they need not be duplicated. For example: The si原创 2016-11-01 20:45:19 · 718 阅读 · 0 评论 -
AC自动机--------hdu 2222
AC自动机简介: AC自动机:Aho-Corasick automation,是著名的多模匹配算法之一。一个常见的例子就是给出n个单词,再给出一段包含m个字符的文章,让你找出有多少个单词在文章里出现过。 AC自动机的构造: 1.构造一棵Trie,作为AC自动机的搜索数据结构。 2.构造fail指针,使当前字符失配时跳转到具有最长公共前后缀的字符继续匹配。如同转载 2016-10-02 14:25:57 · 517 阅读 · 0 评论 -
AC自动机---求找出每个字符串出现的具体次数
Description 小t非常感谢大家帮忙解决了他的上一个问题。然而病毒侵袭持续中。在小t的不懈努力下,他发现了网路中的“万恶之源”。这是一个庞大的病毒网站,他有着好多好多的病毒,但是这个网站包含的病毒很奇怪,这些病毒的特征码很短,而且只包含“英文大写字符”。当然小t好想好想为民除害,但是小t从来不打没有准备的战争。知己知彼,百战不殆,小t首先要做的是知道这个病毒网站特征:包含多少不同的病原创 2016-10-28 00:19:19 · 2633 阅读 · 0 评论 -
URAL 1297 后缀数组+RMQ求串的最长回文子串
Description The “U.S. Robots” HQ has just received a rather alarming anonymous letter. It states that the agent from the competing «Robots Unlimited» has infiltrated into “U.S. Robotics”. «U.S. R原创 2016-11-06 19:23:27 · 431 阅读 · 0 评论 -
SPOJ DISUBSTR-----后缀数组求串的子串的个数
Description Given a string, we need to find the total number of its distinct substrings. Input T- number of test cases. T Each test case consists of one string, whose length is Output For e原创 2016-11-04 22:42:01 · 536 阅读 · 0 评论 -
poj 1743 后缀数组+二分答案 求一个串的最长无重叠的重复出现次数最多的子串
Description A musical melody is represented as a sequence of N (1<=N<=20000)notes that are integers in the range 1..88, each representing a key on the piano. It is unfortunate but true that this re原创 2016-11-04 19:30:28 · 512 阅读 · 0 评论 -
poj 3294 求多于k个字符串的最长公共子串的个数-------后缀数组+二分答案
Description You may have wondered why most extraterrestrial life forms resemble humans, differing by superficial traits such as height, colour, wrinkles, ears, eyebrows and the like. A few bear n原创 2016-11-03 20:30:54 · 531 阅读 · 0 评论 -
后缀数组 相关问题模板
后缀数组函数模板: const int MAX=200020; int wa[MAX],wb[MAX],wsf[MAX],wv[MAX],sa[MAX]; int rank[MAX],height[MAX],r[MAX]; string str1,str2; int cmp(int *r,int a,int b,int k) { return (r[a]==r[b])&&(r[a+k]=原创 2016-05-18 20:46:28 · 384 阅读 · 0 评论 -
UVALive 3942 字典树+dp
题意:给出一个字符串和n个不同的单词,求单词构成字符串的组合数,单词可以多次使用 题解:此字符串可以分解,dp[i]是此字符串的后缀str[i~len-1]的组成种数,则dp[i]=sum(dp[i+len(x)]|前缀为x(0~i-1)) 建立一棵字典树,就可以在字典树上的一个分支上dp求解 #include #include #include #include #include原创 2017-05-03 19:15:07 · 433 阅读 · 0 评论