The Dominator of Strings Time Limit: 3000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Problem Description Here you have a set of strings. A dominator is a string of the set dominating all strings else. The string S is dominated…
hdu 6208 The Dominator of Strings[AC自动机] 求一个串包含其他所有串,找出最长串去匹配即可,但是匹配时要对走过的结点标记,不然T死QAQ,,扎心了.. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<queue> using namespace std; inline )+=c-';} ; ;…
The Dominator of Strings Time Limit: 3000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total Submission(s): 2830    Accepted Submission(s): 1010 Problem Description Here you have a set of strings. A dominator is a string of the…
https://vjudge.net/problem/HDU-6208 首先可以知道最长那个串肯定是答案 然后,相当于用n - 1个模式串去匹配这个主串,看看有多少个能匹配. 普通kmp的话,每次都要O(mxLen)的复杂度肯定不行.考虑AC自动机,不说这个算法了都懂. 大概就是,询问主串的时候用Fail指针快速转移到LCP,然后就可以用字典树快速判断其是否一个模式串 可以知道判断过的可以标记下,不需要再判断了(听说很多人TLE在这里了,比赛的时候写歪了也TLE) #include <bits/…
Problem Description Here you have a set of strings. A dominator is a string of the set dominating all strings else. The string S is dominated by T if S is a substring of T .   Input The input contains several test cases and the first line provides th…
最长的才可能成为答案,那么除了最长的以外全部insert到自动机里,再拿最长的去match,如果match完以后cnt全被清空了,那么这个最长串就是答案.事实上方便起见这个最长串一起丢进去也无妨,而且更好写(时间也没有慢特别多). 另外需要注意的一点是init()里头的memset只需要清空之前用过的节点而不是所有节点,这是经常被卡的一点. 代码如下: #include <stdio.h> #include <algorithm> #include <string.h>…
Description Given two strings, you have to tell the length of the Longest Common Substring of them. For example:str1 = bananastr2 = cianaic So the Longest Common Substring is "ana", and the length is 3. Input The input contains several test case…
MZL's Circle Zhou Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Problem Description   MZL's Circle Zhou is good at solving some counting problems. One day, he comes up with a counting problem:You are given two…
用后缀自动机统计出出现1~n次的串的数量f[i] 对于ans[k]=sigma(f[i]*C(i,k)) i>=k ; mo=; ..maxn] of dword; nt:..maxn,'a'..'z'] of longint; last,sum,i:dword; s:ansistring; eg:..maxn*] of record nt,v:dword; end; lt:..maxn] of dword; el:dword; time:..maxn] of qword; T,j,TT:dwo…
上学期很认真地学了一些字符串的常用工具,各种 suffix structre,但是其实对后缀自动机这个部分是理解地不太透彻的,以致于看了师兄A这题的代码后,我完全看不懂,于是乎重新看回一些学习后缀自动机的博客和代码,重新理解了一些概念,感觉自己对于后缀自动机的理解深了一些. 先说说题意,给了三个串,问对于长度为x的串,满足(i1,i2,i3)(s1[i1..i1+k-1]==s2[i2...i2+k-1]==s3[i3+i3+k-1])有多少组,要输出全部的组数. 师兄的代码的做法是这样的,插入…