随笔分类 -  ACM_字符串

摘要:通道题意:最大周期串有多少个,子串不算。思路:建好SAM后,fail和next跳,删除前缀相同和后缀相同即可代码:#include #include #include #include #include #include using namespace std;const int MAX_N = 2... 阅读全文
posted @ 2015-09-27 19:55 mithrilhan 阅读(231) 评论(0) 推荐(0)
摘要:通道题意:给出只有AB组成的字符串S,求第k个不在S中出现的串T。思路:我们可以把原串中logK左右的串都拿出来排序。然后直接二分答案求解即可代码:#include #include #include #include #include using namespace std;typedef lon... 阅读全文
posted @ 2015-09-20 11:00 mithrilhan 阅读(254) 评论(0) 推荐(0)
摘要:通道题意:首尾加字符,询问多少个本质不同的回文串和多少个不同回文串思路:标记即可,分别维护左右last指针代码:#include #include typedef long long ll;template inline bool rd(T &ret) { char c; int sgn; ... 阅读全文
posted @ 2015-09-01 14:19 mithrilhan 阅读(125) 评论(0) 推荐(0)
摘要:通道题意:按要求建一棵树,求树上的价值=sum(len*cnt),len为回文长度,cnt为该回文在树上出现了多少次思路:建好树从0开始往下跑就可以了,每跑完一条链,就回溯下。代码:#pragma comment(linker, "/STACK:102400000,102400000")#inclu... 阅读全文
posted @ 2015-08-15 22:40 mithrilhan 阅读(337) 评论(0) 推荐(0)
摘要:通道题意:相交回文对数思路:用总的方案数减去不相交方案数,注意内存优化,邻接表表示代码:#include #include #include #include using namespace std;typedef long long ll;typedef pair pii;const int MA... 阅读全文
posted @ 2015-08-15 21:32 mithrilhan 阅读(340) 评论(0) 推荐(0)
摘要:通道题意:求不相交回文对数思路:dp[i]代表以i为结尾有多少个回文,然后在求个前缀和,dp[i]就代表[1,i]以每一个结尾共有多少个,然后结果就是sum(dp[i-1]*add(s[len-i-1]))代码:#include #include #include using namespace s... 阅读全文
posted @ 2015-08-15 21:31 mithrilhan 阅读(201) 评论(0) 推荐(0)
摘要:通道题意:求所有回文按长度排序后,前k个奇数长度的子串乘积之和。思路:len[i]代表长度为i的有多少个子串,避免超时,树状数组维护即可代码:#include #include #include using namespace std;typedef long long ll;const int M... 阅读全文
posted @ 2015-08-15 21:31 mithrilhan 阅读(172) 评论(0) 推荐(0)
摘要:通道 阅读全文
posted @ 2015-08-15 21:30 mithrilhan 阅读(140) 评论(0) 推荐(0)
摘要:通道题意:2个字符串,求相同的回文串对数 (S, T), 其中S == T思路:由于并不需要本质不同,所以需要count一下,然后相同部分肯定dfs是一样的,累加即可。代码:#include #include #include using namespace std;typedef long lon... 阅读全文
posted @ 2015-08-15 21:28 mithrilhan 阅读(234) 评论(0) 推荐(0)
摘要:通道题意:求最长不相交双回文串思路:dp1[i]表示[1,i]的回文串,dp2[i]表示[i+1,len]的回文串,ans=max(dp1[i]+dp2[i]);代码:#include #include #include using namespace std;typedef long long l... 阅读全文
posted @ 2015-08-15 21:27 mithrilhan 阅读(168) 评论(0) 推荐(0)
摘要:通道题意:每加入一个字符,求增加了多少个本质不同的子串思路:可知增量要么1要么0,避免超时,字符输出即可。代码:#include #include #include using namespace std;typedef long long ll;const int MAX_N = 5000005;... 阅读全文
posted @ 2015-08-15 21:25 mithrilhan 阅读(192) 评论(0) 推荐(0)
摘要:通道题意:定义一个字符串的子串的值为该子串的长度乘以数量,求这个最大值思路:直接统计即可。代码:#include #include #include using namespace std;typedef long long ll;const int MAX_N = 600005;const int... 阅读全文
posted @ 2015-08-15 21:24 mithrilhan 阅读(168) 评论(0) 推荐(0)
摘要:通道题意:求每读入一个字符,对答案贡献了多少个本质不同的回文串。思路:我们知道回文自动机上每个节点就代表不同的回文串,所以统计节点数即可。代码:#include #include const int MAX_N = 600005;const int SIG = 26 ;struct PTree { ... 阅读全文
posted @ 2015-08-15 21:23 mithrilhan 阅读(178) 评论(0) 推荐(0)
摘要:转自:http://blog.csdn.net/u013368721/article/details/42100363今天我们来学习一个神奇的数据结构:Palindromic Tree。中译过来就是——回文树。那么这个回文树有何功能?假设我们有一个串S,S下标从0开始,则回文树能做到如下几点:1.求... 阅读全文
posted @ 2015-08-15 21:20 mithrilhan 阅读(248) 评论(0) 推荐(0)
摘要:通道题意:从A,B分别取出子串X,Y,求多少种不同的X+Y思路:代码:#include #include #include using namespace std;const int MAX_N = 200007;typedef unsigned long long ll;struct SAM { ... 阅读全文
posted @ 2015-08-04 22:34 mithrilhan 阅读(358) 评论(0) 推荐(0)
摘要:通道题意:n个A串,n个B串,求如何匹配使得LCP和最大。思路:裸的字典树,当时想复杂了。。。代码: 1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 8 struct Trie { 9 ... 阅读全文
posted @ 2015-07-31 15:38 mithrilhan 阅读(314) 评论(0) 推荐(0)
摘要:通道:http://acm.hnu.cn/online/?action=problem&type=show&id=13108&courseid=296题意:N个匹配串及权值,求完全匹配模式串的最大值。思路:建AC自动机,dp[i]到达i的最大值,dp[i]=max(dp[i-L]+W);代码:htt... 阅读全文
posted @ 2014-11-29 15:27 mithrilhan 阅读(151) 评论(0) 推荐(0)
摘要:通道:题意:思路:代码:TAG: 阅读全文
posted @ 2014-10-17 21:09 mithrilhan 阅读(208) 评论(0) 推荐(0)
摘要:通道:http://codeforces.com/problemset/problem/452/E题意:给了三个串,问对于长度为l的串,满足(i1,i2,i3)(s1[i1..i1+l-1]==s2[i2...i2+l-1]==s3[i3+...i3+l-1])有多少组,输出长度为1-min(|s1... 阅读全文
posted @ 2014-10-17 21:08 mithrilhan 阅读(291) 评论(0) 推荐(0)
摘要:通道:http://www.lydsy.com/JudgeOnline/problem.php?id=2806题意:思路:代码:TAG: 阅读全文
posted @ 2014-10-17 21:07 mithrilhan 阅读(96) 评论(0) 推荐(0)