随笔分类 -  字符串 AC自动机

摘要:"POJ 2778 DNA Sequence" Problem : 给m个只含有(A,G,C,T)的模式串(m include include using namespace std; const int N = 208; const int mo = 100000; int id[128]; st 阅读全文
posted @ 2017-07-17 11:29 rpSebastian 阅读(169) 评论(0) 推荐(0)
摘要:"HDU 2896 病毒侵袭" Problem : 给n个模式串,m个目标串,询问每个目标串含有哪些模式串。 Solution : 将模式串建立AC自动机,对于每个目标串,开一个数组表示每个模式串是否匹配,在AC自动机上跑一遍即可。 c++ include include include using 阅读全文
posted @ 2017-07-16 18:47 rpSebastian 阅读(210) 评论(0) 推荐(0)
摘要:"HDU 2222 Keywords search " Problem : 给若干个模式串,询问目标串中出现了多少个模式串。 Solution : 复习了一下AC自动机。需要注意AC自动机中的fail,和next的含义。fail指向了一个最长的与当前匹配出具有相同后缀的一个前缀节点,next用来转移 阅读全文
posted @ 2017-07-16 17:28 rpSebastian 阅读(177) 评论(0) 推荐(0)