字符串hash - POJ 3461 Oulipo
Oulipo
Problem's Link
----------------------------------------------------------------------------
Mean:
给你一个模式串P和一个母串S,让你统计P串在S串中出现的次数.
analyse:
一开始想到的就是使用KMP,就用KMP写了,93ms,挺快的.
我又用AC自动机写了一遍,万万没想到竟然超时了.
后来看别人有用字符串hash写的,于是又用字符串hash写了一遍,代码30+行,而且速度也挺快,173ms.
字符串hash确实是一个好东西 在字符串hash中又学到了unsigned long long超范围后会自动对2^64取模,省去了手动取模.
Time complexity: O(N+M)
view code
1.字符串hash代码
;
;);
;);
;
));
;
}
2.KMP代码
);
;;;
;;
}
3.AC自动机(TLE)
; ; ;
;
; ; ;
;
;
)
)
;
;
}
--------------------------------------------------------- End.
转载请注明:http://www.cnblogs.com/crazyacking/
字符串hash - POJ 3461 Oulipo的更多相关文章
- POJ 3461 Oulipo(乌力波)
POJ 3461 Oulipo(乌力波) Time Limit: 1000MS Memory Limit: 65536K [Description] [题目描述] The French autho ...
- HDU 1686 Oulipo / POJ 3461 Oulipo / SCU 2652 Oulipo (字符串匹配,KMP)
HDU 1686 Oulipo / POJ 3461 Oulipo / SCU 2652 Oulipo (字符串匹配,KMP) Description The French author George ...
- POJ 3461 Oulipo(字符串hash)
题目链接 字符串hash判断字符串是否相等. code #include<cstdio> #include<algorithm> #include<cstring> ...
- POJ 3461 Oulipo
E - Oulipo Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit ...
- POJ 3461 Oulipo[附KMP算法详细流程讲解]
E - Oulipo Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit ...
- POJ 3461 Oulipo 【KMP统计子串数】
传送门:http://poj.org/problem?id=3461 Oulipo Time Limit: 1000MS Memory Limit: 65536K Total Submission ...
- POJ 3461 Oulipo(模式串在主串中出现的次数)
题目链接:http://poj.org/problem?id=3461 题意:给你两个字符串word和text,求出word在text中出现的次数 思路:kmp算法的简单应用,遍历一遍text字符串即 ...
- HDU 1686 Oulipo , 同 POJ 3461 Oulipo (字符串匹配,KMP)
HDU题目 POJ题目 求目标串s中包含多少个模式串p KMP算法,必须好好利用next数组,, (kmp解析)——可参考 海子的博客 KMP算法 //写法一: #include<string ...
- poj 3461 Oulipo(KMP模板题)
Oulipo Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 36903 Accepted: 14898 Descript ...
随机推荐
- Jquery+artTemplate+layPage 封装datagrid
导言 在日常开发中经常会用到列表,相信用过easyui,Ext等很多,的确很强大,但想修改确实也不容易,我也用了几年的easyui,有时间时会想一下,自已随然没有前端的精湛技术,但可以在有这些技术的开 ...
- [LeetCode] Serialize and Deserialize Binary Tree
Serialize and Deserialize Binary Tree Serialization is the process of converting a data structure or ...
- String和包装类Integer\Double\Long\Float\Character 都是final类型
String和包装类Integer\Double\Long\Float\Character\Boolean 都是final类型 不可以改变
- mac下忘记mysql密码, 重新设置mysql密码
step1: 苹果->系统偏好设置->最下边点mysql 在弹出页面中 关闭mysql服务(点击stop mysql server)step2:进入终端输入:cd /usr/local/m ...
- golang全文搜索--使用sphinx
不多废话,测试环境 `ubuntu 13.10` ## 安装 sudo apt-get install sphinxsearch ## 配置 nano /etc/sphinxsearch/sphinx ...
- IOC错误
问题描述: The type DbConnection cannot be constructed. You must configure the container to supply this v ...
- SVN的文件夹链接(目录链接,目录映射,svn:externals)
首先大家可以看下SVN的文件夹链接太强大了!(目录链接,目录映射,svn:externals),我就是看了这篇文章才敢大刀阔斧的把项目里的外链修改成正确的链接. 问题: 我们的项目里,服务器脚本工程s ...
- Request is not available in this context
部署到新服务器的IIS的时候发现这个错误: Request is not available in this context 解决方案: <system.web> <customEr ...
- cocos2dx 2.x 骨骼动画优化
本文原链接:http://www.cnblogs.com/zouzf/p/4450861.html 公司用的骨骼动画的版本貌似还停留在2.1之前的年代而已没有更新,该因各种历史原因吧,而有个大项目“一 ...
- Cocos2dx 把 glview 渲染到 Qt 控件上(Mac 环境)
本文原链接:http://www.cnblogs.com/zouzf/p/4423256.html 环境:Mac 10.9.2 Xcode5.1.1 Qt5.3 cocos2dx-2.2.4 ...