![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
字符串
sxk_sxy
努力用自己辛勤的汗水,成为一名真正的ACMer
展开
-
Codeforces Round #283 (Div. 2)---B. Secret Combination (暴力)
Secret Combinationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou got a box with a combination lock.原创 2014-12-18 09:06:09 · 1087 阅读 · 0 评论 -
hihoCoder #1036 : Trie图 (AC自动机)
#1036 : Trie图时间限制:20000ms单点时限:1000ms内存限制:512MB描述前情回顾上回说到,小Hi和小Ho接受到了河蟹先生伟大而光荣的任务:河蟹先生将要给与他们一篇从互联网上收集来的文章,和一本厚厚的河蟹词典,而他们要做的是判断这篇文章中是否存在那些属于河蟹词典中的词语。当时,小Hi和小Ho的水平还是原创 2015-07-20 17:08:39 · 1397 阅读 · 0 评论 -
LA 3026 Period (strings)
PeriodTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescriptionFor each prefix of a given string S with N characters (原创 2015-07-21 12:07:41 · 727 阅读 · 0 评论 -
HDU 2896 病毒侵袭 (AC自动机)
题目链接:病毒侵袭解析:利用end数组记录各病毒的编号,然后统计即可。AC代码:#include using namespace std;const int maxn = 502;const int max_word = 202;const int max_text = 10002;const int sigma_size = 128;s原创 2015-07-31 23:27:57 · 554 阅读 · 0 评论 -
HDU 3065 病毒侵袭持续中 (AC自动机)
题目链接:病毒侵袭持续中解析:用end数组标记病毒编号,用used数组记录各个病毒出现的次数,最后对应输出即可。AC代码:#include using namespace std;const int maxn = 1002;const int max_word = 52;const int max_text = 2000002;const i原创 2015-08-01 00:01:45 · 612 阅读 · 0 评论 -
HDU 2222 Keywords Search (AC自动机)
题目链接:Keywords Search解析:直接开个end数组,统计一下即可。AC代码:#include using namespace std;const int max_word = 500005;const int sigma_size = 26;const int max_text = 1000005;struct Trie{原创 2015-07-31 15:41:00 · 557 阅读 · 0 评论 -
POJ 1625 Censored! (AC自动机 + 高精度 + DP)
题目链接:Censored!解析:AC自动机 + 高精度 + 简单DP。字符有可能会超过128,用map映射一下即可。中间的数太大,得上高精度。用矩阵快速幂会超时,简单的DP就能解决时间的问题。AC代码:#include #include #include #include #include #include using name原创 2015-08-13 22:50:51 · 720 阅读 · 0 评论 -
HDU 2825 Wireless Password (AC自动机 + 状态压缩DP)
题目链接:Wireless Password解析:给 m 个单词构成的集合,统计所有长度为 n 的串中,包含至少 k 个单词的方案数。AC自动机 + 状态压缩DP。DP[i][j][k]:长度为i的字符串匹配到状态j且包含k个magic word的可能字符串个数。AC代码:#include #include #include #include #原创 2015-08-15 16:09:43 · 666 阅读 · 0 评论 -
HDU 2296 Ring (AC自动机 + DP)
题目链接:Ring解析:m个有价值的串,字符串s在字符串str中的价值 = s在str中出现的次数 × s的价值。问价值最大的长度为n的串是什么。本题需要输出字典序最小的在DP的时候开一个数组记录结果即可。AC代码:#include #include #include #include #include using namespace std;原创 2015-08-15 17:37:25 · 624 阅读 · 0 评论 -
HDU 2457 DNA repair (AC自动机 + DP)
题目链接:DNA repair解析:给出n个致病DNA序列,给一段DNA片段,问最少修改多少个碱基才能修复这段DNA序列中的所有致病序列。AC自动机 + DP。将n个致病DNA序列构成一个自动机。令DP[i][j]表示长度为i走到节点j是所需改变的最少个数。状态转移时,枚举下一步所有可能的碱基,然后判断该碱基是否达到匹配状态,若能,则安全转移,继续枚举下一个碱基;否则在原创 2015-08-17 11:49:59 · 633 阅读 · 0 评论 -
ZOJ 3228 Searching the String (AC自动机)
题目链接:Searching the String解析:给一个长串,给n个不同种类的短串,问分别在能重叠下或者不能重叠下短串在长串中出现的次数。能重叠的已经是最简单的AC自动机模板题了。不能重叠的记录一下每个匹配的串的起始位置保证不重叠即可。AC代码:#include using namespace std;struct Trie{ int原创 2015-08-17 17:24:36 · 864 阅读 · 0 评论 -
HDU 3247 Resource Archiver (AC自动机 + BFS + 状态压缩DP)
题目链接:Resource Archiver解析:n个正常的串,m个病毒串,问包含所有正常串(可重叠)且不包含任何病毒串的字符串的最小长度为多少。AC自动机 + bfs + 状态压缩DP用最短路预处理出状态的转移。可以优化很多AC代码:#include #include #include #include #include using name原创 2015-08-18 11:39:04 · 718 阅读 · 0 评论 -
HDU 3341 Lost's revenge (AC自动机 + DP)
题目链接:Lost's revenge解析:n个模式串,一个目标串。问目标串通过任意次交换字符最多能包含的模式串个数。(允许重叠)字符最长是40只需要记录ACGT出现的次数。如果使用5维数组,显然超内存了。假设ACGT的总数分别为num[0],num[1],num[2],num[3]那么对于ACGT的数量分别为ABCD的状态可以记录为: (网上大神讲的原创 2015-08-18 10:39:53 · 644 阅读 · 0 评论 -
ZOJ 3494 BCD Code (AC自动机 + 数位DP)
题目链接:BCD Code解析:n个病毒串,问给定区间上有多少个转换成BCD码后不包含病毒串的数。非常神奇的题目。。经典的 AC自动机 + 数位DP 的题目。首先使用AC自动机,得到bcd[i][j]表示状态i,加了数字j以后到达的状态,为-1表示不能转移然后就是数位DP了注意记录为0的状态AC代码:#include #include原创 2015-08-18 13:35:32 · 1155 阅读 · 0 评论 -
HDU 2243 考研路茫茫――单词情结 (AC自动机 + 矩阵快速幂)
题目链接: 考研路茫茫――单词情结做本题前,个人建议先做一下POJ 2778http://blog.csdn.net/u013446688/article/details/47378255POJ2778 是求长度为n,不包含模式串的字符串个数。而本题是求长度为n,包含模式串的字符串个数。直接用字符串总数减去不包含模式串的字符串个数即为所求。同样是原创 2015-08-10 15:39:26 · 1087 阅读 · 2 评论 -
HDU 1075 What Are You Talking About (Trie)
What Are You Talking AboutTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 102400/204800 K (Java/Others)Total Submission(s): 16042 Accepted Submission(s): 5198Problem Descriptio原创 2015-07-16 11:54:42 · 772 阅读 · 0 评论 -
POJ 2778 DNA Sequence (AC自动机 + 矩阵快速幂)
题目链接:DNA Sequence解析:AC自动机 + 矩阵加速(快速幂)。这个时候AC自动机 的一种状态转移图的思路就很透彻了,AC自动机就是可以确定状态的转移。AC代码:#include #include #include #include using namespace std;const int MOD = 100000;str原创 2015-08-09 18:23:19 · 950 阅读 · 0 评论 -
hiho一下 第三周---KMP算法
KMP算法时间限制:1000ms单点时限:1000ms内存限制:256MB描述小Hi和小Ho是一对好朋友,出生在信息化社会的他们对编程产生了莫大的兴趣,他们约定好互相帮助,在编程的学习道路上一同前进。这一天,他们遇到了一只河蟹,于是河蟹就向小Hi和小Ho提出了那个经典的问题:“小Hi和小Ho,你们能不能够判断一段文字(原串)里面是原创 2014-12-13 00:37:52 · 1773 阅读 · 3 评论 -
POJ 2406 Power Strings (KMP next数组应用)
解决这道题的关键,shi学这个定理原创 2014-06-10 15:57:29 · 673 阅读 · 0 评论 -
URAL 1545. Hieroglyphs
1545. HieroglyphsTime limit: 1.0 secondMemory limit: 64 MBVova is fond of anime. He is so enthusiastic about this art that he learned to communicate with his Japanese friends using the原创 2015-03-11 13:52:16 · 703 阅读 · 0 评论 -
URAL 1585. Penguins (字符串)
1585. PenguinsTime limit: 1.0 secondMemory limit: 64 MBProgrammer Denis has been dreaming of visiting Antarctica since his childhood. However, there are no regular flights to Antarctic原创 2015-03-07 16:02:24 · 649 阅读 · 0 评论 -
URAL 1723. Sandro's Book
1723. Sandro's BookTime limit: 0.5 secondMemory limit: 64 MBIt's been quite a number of years since Lich Sandro retired. Sometimes in the evenings, when he feels especially lonely, he原创 2015-03-22 09:01:29 · 862 阅读 · 0 评论 -
URAL 1601. AntiCAPS (strings)
1601. AntiCAPSTime limit: 0.5 secondMemory limit: 64 MBThe blonde Angela has a new whim: internet chats. Of course, as any blonde, shewrites her messages using the upper case. You are the原创 2015-06-24 11:45:09 · 750 阅读 · 0 评论 -
hihoCoder 1014 Trie树 (Trie)
#1014 : Trie树时间限制:10000ms单点时限:1000ms内存限制:256MB描述小Hi和小Ho是一对好朋友,出生在信息化社会的他们对编程产生了莫大的兴趣,他们约定好互相帮助,在编程的学习道路上一同前进。这一天,他们遇到了一本词典,于是小Hi就向小Ho提出了那个经典的问题:“小Ho,你能不能对于每一个我给出的字符串,原创 2015-07-12 11:05:17 · 802 阅读 · 0 评论 -
HDU 1251 统计难题 (Trie)
统计难题Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131070/65535 K (Java/Others)Total Submission(s): 22182 Accepted Submission(s): 9391Problem DescriptionIgnatius最近遇到一个难题,老师交给原创 2015-07-13 08:21:16 · 889 阅读 · 0 评论 -
HDU 1671 Phone List (Trie)
Phone ListTime Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 12879 Accepted Submission(s): 4391Problem DescriptionGiven a list of原创 2015-07-13 09:32:25 · 544 阅读 · 0 评论 -
HDU 1075 What Are You Talking About (strings)
What Are You Talking AboutTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 102400/204800 K (Java/Others)Total Submission(s): 15966 Accepted Submission(s): 5177Problem Descriptio原创 2015-07-13 10:37:07 · 757 阅读 · 0 评论 -
UVA 11732 "strcmp()" Anyone? (Trie)
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2832题意:模拟strcmp()函数,给n个字符串,两两之间进行比较,问需要进行多少次比较?解析:字符串很多,数据量大,按题意两两比较显然不现实。如果把所有的单词插入到一棵Tr原创 2015-07-14 10:10:50 · 641 阅读 · 0 评论 -
UVA 3942 - Remember the Word (Trie)
3942 - Remember the WordNeal is very curious about combinatorial problems, and now here comes a problem about words. Knowing that Ray has a photographic memory and this may not trouble him, Neal原创 2015-07-14 16:27:11 · 923 阅读 · 0 评论 -
ZOJ 3430 Detect the Virus (AC自动机)
题目链接:Detect the Virus题意:n个模式串,一个文本串,问文本串包含几个模式串。解析:解码 + AC自动机。 解码过程:先将字符串转换成ASCII 然后根据相应的ASCII 转换成二进制,每一个是6位,不够加0,然后取8位为一个字符,求得的字符串为要的字符串。PS:注意sigma_size = 256AC代码:原创 2015-08-08 17:09:06 · 739 阅读 · 0 评论 -
弱校联萌十一大决战之强力热身 C. Censor (KMP + stack)
C. CensorTime Limit: 2000msMemory Limit: 65536KB 64-bit integer IO format: %lld Java class name: MainSubmit Statusfrog is now a editor to censor so-called sensitive words (敏感词).She has a lon原创 2015-10-03 13:19:37 · 1262 阅读 · 0 评论