[题解]GREWords(AC自动机) SP9941 GRE - GRE Words 题目大意: 给定一个由字符串构成的序列,不同位置的字符串有自己权值.现在让你选出一个子序列,使得在这个子序列中,前面的串是后面的串的子串.请你求满足条件的子序列的权值的最大值.一个子序列权值是所有元素权值的和. 考虑一个朴素的DP做法,设\(dp(i)\)表示选择了字符串\(i\)的最大权值子序列,转移直接枚举前面的字符串,通过\(kmp\)判断是否为子串,然后转移,复杂度\(O(n^3)\) 考虑优化一下上面…
题目描述 Farmer John has purchased a subscription to Good Hooveskeeping magazine for his cows, so they have plenty of material to read while waiting around in the barn during milking sessions. Unfortunately, the latest issue contains a rather inappropria…
[HDU2896]病毒侵袭 Problem Description 当太阳的光辉逐渐被月亮遮蔽,世界失去了光明,大地迎来最黑暗的时刻....在这样的时刻,人们却异常兴奋--我们能在有生之年看到500年一遇的世界奇观,那是多么幸福的事儿啊~~但网路上总有那么些网站,开始借着民众的好奇心,打着介绍日食的旗号,大肆传播病毒.小t不幸成为受害者之一.小t如此生气,他决定要把世界上所有带病毒的网站都找出来.当然,谁都知道这是不可能的.小t却执意要完成这不能的任务,他说:"子子孙孙无穷匮也!"(愚…
[HDU2222]Keywords Search Problem Description In the modern time, Search engine came into the life of everybody like Google, Baidu, etc.Wiskey also wants to bring this feature to his image retrieval system.Every image have a long description, when use…