摘要: 拜读了大牛们的代码,对AC自动机的了解又加深了一步。 不过刚才去一个QQ群推荐的题集里看了下,里面的题目还是不能顺利的解决,看来还需要更深入的去了解。 下面是hdu2222的题解,感觉可以作为不错的AC自动机模板代码。#include<iostream>usingnamespacestd;constintkind=26;structnode{node*fail;//失败指针node*next[kind];//Tire每个节点的26个子节点(最多26个字母)intcount;//是否为该单词的最后一个节点node(){//构造函数初始化fail=NULL;count=0;memset 阅读全文
posted @ 2011-10-10 23:04 追逐. 阅读(703) 评论(0) 推荐(0)
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1873 主要是排序,sort和qsort是不稳定排序,所以在此题种不可用。而stable_sort为稳定排序,每次IN后对vector排序即可。#include<iostream>#include<vector>#include<algorithm>usingnamespacestd;structpain{inttip,id;};intcmp(paina,painb){returna.tip>b.tip;}intmain(){intn;typedefvect 阅读全文
posted @ 2011-10-10 12:16 追逐. 阅读(268) 评论(0) 推荐(0)