
字符串
u010660276
这个作者很懒,什么都没留下…
展开
-
2015 Multi-University Training Contest 7(hdu5371、5372、5373、5375、5378、5379)(dp+概率Manachar+dfs计数+树状数组)
Hotaru’s problemProblem DescriptionHotaru Ichijou recently is addicated to math problems. Now she is playing with N-sequence. Let’s define N-sequence, which is composed with three parts and satisfied原创 2015-08-11 23:28:50 · 549 阅读 · 0 评论 -
KMP矩阵匹配poj2185
Language:DefaultMilking GridTime Limit: 3000MS Memory Limit: 65536KTotal Submissions: 6291 Accepted: 2629DescriptionEvery morning when they are milked, th原创 2014-08-15 20:17:22 · 546 阅读 · 0 评论 -
字符串汇总
[汇总]字符串题目推荐及解题报告说明:小弟才疏学浅,最近发现此文点击率较高,还有一些转载,实在是万分惭愧。这份题目推荐里面,实在水题烂题太多,上不得台面,等今年赛区赛结束后,本菜一定好好清理下此贴。POJ 1002 - 487-3279(基础)http://acm.pku.edu.cn/JudgeOnline/problem?id=1002题意:略解法:二叉查找数,ma转载 2014-08-14 10:56:24 · 467 阅读 · 0 评论 -
扩展KMP+矩阵快速幂
扩展KMP:给出模板串A和子串B,长度分别为lenA和lenB,要求在线性时间内,对于每个A[i](0原创 2014-06-16 13:57:37 · 516 阅读 · 0 评论 -
Codeforces Round #246 (Div. 2)
C. Prime SwapsYou have an array a[1], a[2], ..., a[n], containing distinct integers from1 to n. Your task is to sort this array in increasing order with the following operation (you may need t原创 2014-06-20 17:34:36 · 532 阅读 · 0 评论 -
后缀数组(出现两次的子串且不重叠)hdu3518
Online JudgeOnline ExerciseOnline TeachingOnline ContestsExercise AuthorF.A.QHand In HandOnline AcmersForum | DiscussStatistical ChartsProblem ArchiveRealtime Judge Statu原创 2014-07-31 22:11:16 · 647 阅读 · 0 评论 -
AC自动机uva11468
详见《训练指南》// UVa11468 Substring// Rujia Liu#include#include#include#include#include#includeusing namespace std;const int SIGMA_SIZE = 64;const int MAXNODE = 500; // 结点总数const int MAXS = 20原创 2014-03-26 22:54:51 · 511 阅读 · 0 评论 -
扩展KMP+hdu3613
题意:给个字符串S,要把S分成两段T1,T2,每个字母都有一个对应的价值,如果T1,T2是回文串,那么他们就会有一个价值,这个价值是这个串的所有字母价值之和,如果不是回文串,那么这串价值就为0。问最多能获得多少价值 对于我们只需要枚举扫描一遍extend数组,扫描到的当前位置之前为前半部分T1, 然后用根据extend数组可以判断T1是否是回文。那后半部分T2呢? 刚才是用S去匹配T,原创 2014-07-10 14:59:44 · 524 阅读 · 0 评论 -
后缀数组poj2774(hdu1403)ural1517
思路:把两个串拼接起来然后求原创 2014-07-01 10:53:07 · 461 阅读 · 0 评论 -
后缀数组(不同的回文字串)hdu3948
调了一上午终于调出来了,这都是什么错误,为什么原创 2014-07-06 11:21:13 · 731 阅读 · 0 评论 -
Trie树(字典树)poj3630+hdu1671
Language:DefaultPhone ListTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 22737 Accepted: 7030DescriptionGiven a list of phone numbers, determ原创 2014-08-17 13:01:58 · 572 阅读 · 0 评论 -
Manacher(枚举位置)+uva11888
Abnormal 89's A palindrome is a word that can be read the same way in either direction. More formally if a string isd (d > 0) characters length and thei-th character is ai, the string原创 2014-09-13 22:54:36 · 525 阅读 · 0 评论 -
Codeforces Round #313 (Div. 2)D. Equivalent Strings(字符串)
D. Equivalent StringsToday on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases:They are e原创 2015-07-25 11:36:23 · 483 阅读 · 0 评论 -
hdu 4495 - Rectangle(hash+二分+dp)
Rectangle Time Limit: 10000/10000 MS (Java/Others) Memory Limit: 65535/102400 K (Java/Others) Total Submission(s): 344 Accepted Submission(s): 100Problem Description Given a rectangle which co原创 2015-07-11 22:28:37 · 609 阅读 · 0 评论 -
构造字符串(hdu2970Suffix reconstruction)
Suffix reconstructionTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 278 Accepted Submission(s): 150Problem DescriptionGiven a t原创 2015-03-18 22:56:04 · 519 阅读 · 0 评论 -
后缀自动机(最长公共子串、模板)spoj1811
今天又把后缀自动机看了一遍,终于看明白了.先说一下后缀自动机的几条性质:1.从初始状态出发,所有到达终止状态的串是后缀2.从起点出发到达每个节点的路径是串的所有子串3.从一个接受态沿Parent走到达的还是接受态4.一个节点及其父辈代表的船有相同的后缀,且长度递减还有就是后缀自动机的构造过程,下面给大家推荐几个博客:后缀自动机(FHQ+Neroysq补完)后缀自原创 2015-01-01 10:45:06 · 1580 阅读 · 0 评论 -
后缀自动机poj1509
今天终于知道什么是后缀自动机了,知道他长啥样了,知道他的几个性质了,但是构造的过程还没太明白,对于用节点维护某些东西肯定还不行,先敲一道水题,算整理一下模板poj1509有最小表示法的算法,这里中后缀自动机求解。思路:把串重复一边加到后面,然后构造后缀自动机,然后从根遍历字符串长度,得到位置#include#include#include#include#include#in原创 2014-12-30 16:26:14 · 951 阅读 · 1 评论 -
字符串hash+hdu4821(2013长春现场赛)
Online JudgeOnline ExerciseOnline TeachingOnline ContestsExercise AuthorF.A.QHand In HandOnline AcmersForum | DiscussStatistical ChartsProblem ArchiveRealtime Judge Statu原创 2014-09-24 21:30:12 · 608 阅读 · 0 评论 -
hash(2014北京邀请赛)bnu34990
Current Server Time: 2014-09-26 20:01:43Justice StringTime Limit: 2000msMemory Limit: 65536KB64-bit integer IO format: %lld Java class name: MainPrev Submit Status Statistic原创 2014-09-26 20:01:20 · 629 阅读 · 0 评论 -
最小表示法+uva719
首先讲一下字符串的循环表示,下面的原创 2014-09-14 10:21:25 · 656 阅读 · 1 评论 -
KMP
好久没写过KMP了,都忘了怎么写了,重写一下温习一遍。int next[maxn];string a;void getNext(){ int j=0,k=-1,len=a.size(); next[0]=-1; while(j<len) { if(k==-1||a[j]==a[k]) { j++,k+原创 2014-01-11 15:22:24 · 491 阅读 · 0 评论 -
KMP+poj2185
找出每行的重复子串长度的各种可能情况,然后每行都有的并且是最小长度作为宽width。第二步找最小重复子矩阵的高,这个思路和网上的差不多,取每行的宽为width的前缀作为一个单位,对这0到r-1个单位求出KMP的next函数,找出最小重复子序列的单位数作为高height,最终答案为width*height。转载 2014-07-10 21:14:46 · 508 阅读 · 0 评论 -
Manacher+hdu4513
题意:要求中间高两边低的最长回文子序列思路:我用Manacher原创 2014-07-10 16:13:40 · 540 阅读 · 0 评论 -
扩展KMP+hdu4300
题意:首先给一个字母转化表,然后给一个密文+明文原创 2014-07-10 09:41:19 · 497 阅读 · 0 评论 -
后缀数组(不相同子串的个数)spoj694
突然发现前面写的后缀数组不太对,拍出来的sa原创 2014-07-03 14:13:50 · 581 阅读 · 0 评论 -
Codeforces Round #244 (Div. 2)(强连通分量,后缀数组)
A. Police Recruits#include#include#include#includeusing namespace std;int n;int main(){ //freopen("in.txt","r",stdin); cin>>n; int ans=0,x,p=0; for(int i=0;i<n;i++) {原创 2014-05-23 20:08:33 · 868 阅读 · 0 评论 -
后缀数组(最长回文字串)ural1297
也可以用KMP做具体参见原创 2014-07-03 17:32:06 · 475 阅读 · 0 评论 -
后缀数组(每个字符串至少出现两次且不重叠的最长子串)spoj220
调了一晚上死活没调出来,原创 2014-07-05 21:45:44 · 625 阅读 · 0 评论 -
KMP+poj3461
#include#includeusing namespace std;const int maxw=10000+10;const int maxt=1000000+10;char word[maxw];char text[maxt];int suffix[maxw];int make(){ int i,j; int num=0; int p=0,cur=原创 2014-02-22 20:59:05 · 547 阅读 · 0 评论 -
后缀数组+二分poj3261
题意:找出一个最长的并且重复次数至少为k次的子串。原创 2014-07-01 11:43:06 · 446 阅读 · 0 评论 -
扩展KMP模板
#includeusing namespace std;const int N = 101010;int next[N],extand[N];void getnext(char *T) // next[i]: 以第i位置开始的子串 与 T的公共前缀{ int n=strlen(T); next[0]=n; int j=0; while(j+1<n&&T[j原创 2014-06-16 14:10:56 · 542 阅读 · 0 评论 -
KMP求周期uva10298
题意:给出字符串,问其周期注意:len%(i-next[i])==0时代表字符串刚刚是子串的整数倍#include#include#include#include#includeusing namespace std;const int maxn=1000100;int next[maxn];string a;void getnext(){ int i=0,j=原创 2014-03-16 21:52:47 · 624 阅读 · 0 评论 -
后缀数组+LCP+多个串找公共子序列+uva11107
详见训练指南,需要注意的细节太多了#include#include#include#include#includeusing namespace std;const int MAXN=100010;int n;struct Suffix{ int s[MAXN],sa[MAXN]; int height[MAXN],rank[MAXN]; int c[原创 2014-02-24 20:56:33 · 595 阅读 · 0 评论 -
后缀数组(不可重叠重复子串)poj1743
思路:二分答案,然后遍历height数组,看能不能找到原创 2014-07-03 09:57:52 · 503 阅读 · 0 评论 -
KMP--poj1754
字符串模式匹配,wa了几次,是自己没搞清楚字符串的前缀函数与原来串的位置关系,有待进一步学习其实这个题还比较简单,写出前缀函数,然后找一下重复子串,出一下就行了,需要注意的是前缀函数中有0,避免做分母。AC代码:#include#include#includeusing namespace std;char c[1000005];int next[1000005];int ma原创 2013-08-13 22:50:55 · 799 阅读 · 0 评论 -
KMP求前缀周期uva1328
#include#include#includeusing namespace std;const int maxn=1000100;int next[maxn],n,ca=1;string a;void getnext() { int j=-1,i=0; next[0]=-1; while(i<n) { if(j==-1|原创 2014-02-22 22:17:39 · 636 阅读 · 0 评论 -
后缀数组(多个穿的最长公共子串)+KMP+poj3080
跟Life Forms很像原创 2014-07-10 22:34:28 · 633 阅读 · 0 评论 -
KMP(后缀数组)uva11475
题意:给定一个串,只能在后面添加字符,使其成为一个回文串。思路:反转后求rev的next函数,然后与原串进行匹配,找到已经是回文的位置,输出#include#include#include#include#includeusing namespace std;const int maxn=100100;int next[maxn];string a,rev;void ge原创 2014-03-18 15:14:06 · 1002 阅读 · 0 评论 -
后缀数组(长度不小于k的公共子串的个数)
把两个串拼接起来,中间用神奇地‘$'字符隔开。然后用倍增算法求sa数组、rank数组、height数组,然后利用height数组统计第一个串称A串的所有后缀与第二个串B串的所有后缀所共有的长度大于k的子串。 上面的逻辑过程容易理解,用aa和aa就能推出为什么答案是5,子串a有2个,aa有1个,2*2 + 1*1 = 5.问题的关键是要找出各个子串总匹配数(子串相等称为匹配)。height数转载 2014-07-04 18:56:12 · 781 阅读 · 0 评论 -
扩展KMP+KMP+hdu4333
自己就是想不到,之上适应萨哈原创 2014-07-10 11:18:26 · 523 阅读 · 0 评论