随笔分类 - 字符串
摘要:快排的代码很容易理解。1intsa[MAX],temp[MAX],rank[MAX];2intn,k;3boolcmp_sa(inti,intj){4if(rank[i]!=rank[j])returnrank[i]<rank[j];5else{6intri=i+k<=n?rank[i+k]:-1;...
阅读全文
摘要:D. Prefixes and SuffixesYou have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several de...
阅读全文
摘要:while(scanf("%s",str+1)==1){intn=strlen(str+1);next[1]=0;intj=0;for(inti=2;i2#include3#include4#include5#include6#include7#include8usingnamespacestd;9...
阅读全文
摘要:题目描述Doyouknowgoagain?Iftheansweris“no”,well,youcanleaveNEUACM.GoagainisthemostperfectACMerinNEUACM,andhisteam’snameisNEU_FirstFinal.Besidesthis,goagai...
阅读全文
摘要:DNA SequenceTime Limit:1000MSMemory Limit:65536KTotal Submissions:10868Accepted:4146DescriptionIt's well known that DNA Sequence is a sequence only contains A, C, T and G, and it's very useful to analyze a segment of DNA Sequence,For example, if a animal's DNA sequence contains segment A
阅读全文
摘要:Phone ListTime Limit:1000MSMemory Limit:65536KTotal Submissions:20894Accepted:6532DescriptionGiven a list of phone numbers, determine if it is consistent in the sense that no number is the prefix of another. Let's say the phone catalogue listed these numbers:Emergency 911Alice 97 625 999Bob 91 1
阅读全文
摘要:题目描述撸呀撸很迷茫,因为他的左手总是不受控制,做一些不雅的事情。于是撸呀撸一狠心,决定戒撸。没想到,他的左手受不了寂寞,一闲下来就在键盘上各种乱敲。唔,神奇的左手表示,safasfasaafafsfafasffsfsfsffsfddfafdfsfadffafadfafadfadfafadfsfa……他发现敲出来的字符串有一定规律:如果将字符串划分成若干部分,那么每部分都可由其子串重复若干次得到。“若干次”往往大于1,但也可以为1。小撸想请你算一算:用最优的方法划分字符串,然后将各部分替换成其最短的连续重复子串,得到的字符串的最小长度是多少?输入格式一行字符,都是英文小写字母。输出格式一个正整
阅读全文
摘要:hdu 3336题意:输入一个字符串求每个前缀在串中出现的次数和sol:只要稍微理解下next 数组的含义就知道只要把每个有意义的next值得个数加起来即可PS:网上有dp解法orz,dp[i]表示以i为前缀串结尾的前缀串的总和,方程很容易写出//字符串上KMP(水)//从前向后扫,失配函数的位置就...
阅读全文
摘要:It is well known that AekdyCoin is good at string problems as well as number theory problems. When given a string s, we can write down all the non-empty prefixes of this string. For example:s: "abab"The prefixes are: "a", "ab", "aba", "abab"For each
阅读全文