![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
字符串
say_c_box
小白不能不努力~
展开
-
字典树入门小结及基础模板详解(HDU1251 HDU1671)
今天开始真正学习字符串相关知识。写了几道字典树入门的题目。第一次总结一下,加深印象。字典树相当于是一种数据结构,每一次从根节点遍历到叶子节点都相当于是查询到这本字典里头的一个单词。节点定义有多种,最简单的只需要一个next数组。(这是以单词为例,所以next数组大小为26,数字的话就只需要10了)struct node{ node *next[26]; node(){ //初原创 2016-07-30 16:40:25 · 414 阅读 · 0 评论 -
扩展kmp模板
#include #include using namespace std;const int N = 101010;int Next[N],extand[N];void getNext(char *T){// Next[i]: 以第i位置开始的子串 与 T的公共前缀 int i,length = (int)strlen(T); Next[0] = length;原创 2017-08-19 22:30:36 · 243 阅读 · 0 评论 -
后缀数组dc3模板(范围1e6而且多样例要用dc3)
#include#include#include#include#include#include#define F(x) ((x)/3+((x)%3==1?0:tb))#define G(x) ((x)<tb?(x)*3+1:((x)-tb)*3+2)using namespace std;const int MAXN = 3e6+10;const int N = MAXN;原创 2017-08-09 19:59:36 · 814 阅读 · 0 评论 -
字典树模板
#include #include #include #include #include #include #include #include using namespace std;const int MAXN=500000+10;struct trie{ int ch[MAXN<<3][30]; int val[MAXN<<3]; int sz;原创 2017-08-27 14:17:38 · 215 阅读 · 0 评论 -
HDU6059 Kanade's trio(异或字典树)
Kanade's trioTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 1067 Accepted Submission(s): 392Problem DescriptionGive you an原创 2017-08-27 14:49:05 · 369 阅读 · 0 评论 -
Gym - 101194F Mr. Panda and Fantastic Beasts (后缀数组)
题意:给出n个字符串,找到最短的字符串,要求仅为第一个字符串的子串。思路:把n个字符串用不出现的字符连接起来。其实就是枚举第一个字符串的每一个子串是否是其他字符串的后缀的前缀即可。#include#include#include #include #include using namespace std;const int MAXN=400000+10;const i原创 2017-08-28 19:36:16 · 1218 阅读 · 0 评论 -
HDU6096 string(字典树)
StringTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 1037 Accepted Submission(s): 335Problem DescriptionBob has a dictiona原创 2017-08-28 20:39:28 · 338 阅读 · 0 评论 -
POJ2406——Power Strings(后缀数组)
Power StringsTime Limit: 3000MS Memory Limit: 65536KTotal Submissions: 51218 Accepted: 21386DescriptionGiven two strings a and b we define a*b to be their conca原创 2017-08-29 20:16:48 · 549 阅读 · 0 评论 -
SPOJ - REPEATS Repeats (后缀数组)
REPEATS - Repeatsno tags A string s is called an (k,l)-repeat if s is obtained by concatenating k>=1 times some seed string t with length l>=1. For example, the string s = abaabaabaaba转载 2017-08-29 20:23:18 · 279 阅读 · 0 评论 -
POJ3693 Maximum repetition substring (后缀数组)
The repetition number of a string is defined as the maximum number R such that the string can be partitioned into R same consecutive substrings. For example, the repetition number of "ababab" is 3 and原创 2017-08-29 20:46:56 · 309 阅读 · 0 评论 -
POJ2774 Long Long Message(后缀数组)
Long Long MessageTime Limit: 4000MS Memory Limit: 131072KTotal Submissions: 31523 Accepted: 12719Case Time Limit: 1000MSDescriptionThe little cat is major原创 2017-08-29 20:52:37 · 297 阅读 · 0 评论 -
POJ3415 Common Substrings(后缀数组,单调栈)
Common SubstringsTime Limit: 5000MS Memory Limit: 65536KTotal Submissions: 11195 Accepted: 3701DescriptionA substring of a string T is defined as:T(i, k)=原创 2017-08-29 21:26:51 · 319 阅读 · 0 评论 -
POJ3294——Life Forms 后缀数组
Life FormsTime Limit: 5000MS Memory Limit: 65536KTotal Submissions: 15912 Accepted: 4695DescriptionYou may have wondered why most extraterrestrial life forms原创 2017-08-29 22:22:59 · 404 阅读 · 0 评论 -
Relevant Phrases of Annihilation SPOJ - PHRASES 后缀数组
PHRASES - Relevant Phrases of Annihilationno tags You are the King of Byteland. Your agents have just intercepted a batch of encrypted enemy messages concerning the date of the planned a原创 2017-08-29 22:41:47 · 369 阅读 · 0 评论 -
HDU6034 Balala Power! (字符串)
Balala Power!Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2709 Accepted Submission(s): 577Problem DescriptionTalente原创 2017-07-26 11:22:58 · 1064 阅读 · 0 评论 -
后缀数组nlogn模板
int t1[maxn],t2[maxn],c[maxn]; bool cmp(int *r,int a,int b,int l) { return r[a]==r[b] &&r[l+a] == r[l+b]; } void get_sa(int str[],int sa[],int Rank[],int height[],int n,int m) {原创 2017-08-09 15:44:03 · 333 阅读 · 0 评论 -
codeforces 832B ——Petya and Exam
B. Petya and Examtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt's hard times now. Today Petya needs to原创 2017-07-25 10:36:30 · 587 阅读 · 0 评论 -
HDU1247——Hat’s Words(map黑科技,字符串)
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Description A hat’s word is a word in the dictionary that is the concatenation of exactly two other words in the dictionar原创 2016-07-30 17:31:01 · 313 阅读 · 0 评论 -
HDU3746——Simpsons’ Hidden Talents(KMP中next数组的应用)
DescriptionCC always becomes very depressed at the end of this month, he has checked his credit card yesterday, without any surprise, there are only 99.9 yuan left. he is too distressed and thinki原创 2016-07-30 17:42:09 · 479 阅读 · 0 评论 -
后缀数组入门——初步理解及模板
后缀数组是跟着白书上面学的,感觉自己大概能理解了,写下来加深印象,以后慢慢学习。所谓后缀就是从一个字符串某个位置开始到其末尾的字串(在KMP里也有这个概念)。包括了空串和该字符串本身。后缀数组就是把所有的字符串后缀按照字典序排列后所得到的数组。在后缀数组的计算中,用到了以下几个关键数组。rank用来记录字符串的排序,sa用来记录开头字符的位置,S用来记录字符串,S[i]表示第i个字符开原创 2016-07-31 16:16:58 · 1265 阅读 · 1 评论 -
POJ3581——Sequence(后缀数组)
白书上的例题,自己敲了一遍,也大概看懂了。SequenceTime Limit: 5000MS Memory Limit: 65536KTotal Submissions: 6452 Accepted: 1414Case Time Limit: 2000MSDescriptionGive原创 2016-07-31 17:10:46 · 598 阅读 · 0 评论 -
POJ2217——Secretary(后缀数组应用)
SecretaryTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 1089 Accepted: 446DescriptionThe basic condition of success of a political party, it is the g原创 2016-07-31 20:36:27 · 378 阅读 · 0 评论 -
HDU5745(2016多校第二场)——La Vie en rose(bitset,动态规划)
La Vie en roseTime Limit: 7000/3500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2329 Accepted Submission(s): 706Problem DescriptionProfessor Zh原创 2016-08-15 20:17:57 · 619 阅读 · 0 评论 -
POJ1509——Glass Beads(字符串的最小表示法)
Glass BeadsTime Limit: 3000MS Memory Limit: 10000KTotal Submissions: 3826 Accepted: 2163DescriptionOnce upon a time there was a famous actress. As you may expec原创 2016-07-31 21:23:31 · 371 阅读 · 0 评论 -
Codeforces Round #367 (Div. 2) D——Vasiliy's Multiset(异或字典树)
D. Vasiliy's Multisettime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAuthor has gone out of the stories ab原创 2016-08-12 13:45:33 · 869 阅读 · 0 评论 -
codeforces471D——MUH and Cube Walls(KMP)
MUH and Cube Wallstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolar bears Menshykov and Uslada from th原创 2016-12-05 23:53:45 · 359 阅读 · 0 评论 -
HDU3294——Girls' research(manacher算法,马拉车算法)
Girls' researchTime Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 2176 Accepted Submission(s): 831Problem DescriptionOne day, sa原创 2017-03-01 21:39:46 · 369 阅读 · 0 评论 -
AC自动机模板
#include#include#includeusing namespace std;const int maxnode=11000;const int sigma_size=26;struct AC_Automata{ int ch[maxnode][sigma_size]; int val[maxnode]; // 每个字符串的结尾结点都有一个非0的val原创 2017-03-23 21:48:27 · 269 阅读 · 0 评论 -
UVALive 3942 - Remember the Word(DP,字典树)
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1943白书P209// test.cpp : 定义控制台应用程序的入口点。//#define _CRT_SECURE_NO_WARNINGS#include原创 2017-03-14 21:53:54 · 362 阅读 · 0 评论 -
POJ1743 Musical Theme(后缀数组,高度数组分组)
Musical ThemeTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 29855 Accepted: 9996DescriptionA musical melody is represented as a sequence of N (1<=N<=原创 2017-07-30 13:46:07 · 243 阅读 · 0 评论 -
POJ3261 Milk Patterns(后缀数组,二分)
Milk PatternsTime Limit: 5000MS Memory Limit: 65536KTotal Submissions: 15837 Accepted: 6993Case Time Limit: 2000MSDescriptionFarmer John has noticed tha原创 2017-07-30 15:23:44 · 248 阅读 · 0 评论 -
马拉车算法模板
#include #include #include using namespace std;void findBMstr(string str0){ string str; str += "$#"; int n=str0.size(); for(int i = 0; i < n; i++){ str += str0[i];原创 2017-08-31 14:26:58 · 1331 阅读 · 0 评论