
字符串处理
tju_virus
这个作者很懒,什么都没留下…
展开
-
hdu2222 Keywords Search
这个题是AC自动机的模板题,尽情的享受吧 愿有一天能有人写出自动AC机,让我们无尽的AC吧 #include #include #include #include using namespace std; const int M = 500010; const int N = 1000010; const int MAX_N = 26; struct TrieNode {原创 2012-08-10 20:28:44 · 327 阅读 · 0 评论 -
TOJ 3849 Sentence Segmentation
这是一道AC自动机与dp结合的题目。 每个单词有一个权值,把一个长的单词分解成所给的几个单词,并要求尽量使所得到的权值最大,如果不能分解成所给的几个单词输出-1。 用dp[i] 表示到i个位置以前的单词分解所能得到的最大权值。那么当我们用ac自动机匹配到一个单词时就要更新 dp[pts+1] = max(dp[pts+1],dp[pts+1 - tmp->cnt] + tmp->value)原创 2012-08-12 12:50:36 · 401 阅读 · 0 评论