摘要: 并查集主要解决图的连通性问题,比如: 1、随意给你两个点,让你判断它们是否连通; 2、问你整幅图一共有几个连通分支;初始化:void init(int size) { for(int i = 0; i using namespace std;int N, E, Answer;int pre... 阅读全文
posted @ 2015-08-02 21:43 蚂蚁吃大象、 阅读(239) 评论(0) 推荐(0) 编辑
摘要: KMP算法一、传统字符串匹配算法/* * 从s中第sIndex位置开始匹配p * 若匹配成功,返回s中模式串p的起始index * 若匹配失败,返回-1 */int index(const std::string &s, const std::string &p, const int sIndex... 阅读全文
posted @ 2015-08-02 18:14 蚂蚁吃大象、 阅读(193) 评论(0) 推荐(0) 编辑