企业如何利用HarmonyOS开发工具提升小程序开发效率与合规性
600
2022-11-09
HDU 6208 The Dominator of Strings (SAM)
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 the total number of cases.For each test case, the first line contains an integer N indicating the size of the set.Each of the following N lines describes a string of the set in lowercase.The total length of strings in each case has the limit of 100000.The limit is 30MB for the input file.
Output
For each test case, output a dominator if exist, or No if not.
Sample Input
310youbetterworsericherpoorersicknesshealthdeathfaithfulnessyoubemyweddedwifebetterworsericherpoorersicknesshealthtilldeathdouspartandpledgeyoumyfaithfulness5abccdeabcdeabcdebcde3aaaaaaaaabaaaac
Sample Output
youbemyweddedwifebetterworsericherpoorersicknesshealthtilldeathdouspartandpledgeyoumyfaithfulnessabcdeNo
题意
给定一些串,问其中是否可以找到一个串满足其他串都是这个串的子串。
思路
显然,去重后我们所要找的这个串一定是所有串中最长的一个,且最长是唯一的。
我们建立最长串的后缀自动机,然后其他串用来匹配即可,若所有都可以匹配成功,则说明当前串即为结果,否则输出 No 。
AC 代码
#include
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~