字符串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 ...
随机推荐
- thinkphp 关联模型配置代码
<?php /** * 公司与部门关联模型 */ class CompanyRelationModel extends RelationModel{ //主表名称 protected $tabl ...
- wdlinux 一键安装
Linux系统(支持CentOS 6.X/7.X.RedHat 6.X.Ubuntu 12.04): ssh登录服务器,执行如下操作即可,需root用户身份安装 wget http://dl.wdli ...
- webdriver实用指南迁移至gitbbok并改名为selenium webdriver从入门到提高
背景 几年前我写了一本关于selenium webdriver的小册子,主要讲了一些selenium在进行测试过程中会遇到的场景以及解决方案,陆陆续续在github上收到了100+的star,在这里我 ...
- Turn off swi-prolog protocol output of ANSI terminal control sequences
To save a record of program execution in prolog, we use the special predicates: protocol and noproto ...
- dede教程之后台登录是自动跳出解决方法
有时也不知道什么原因,登录后台时输入全部正确点确认按钮时却会自动跳出.必须输入http://你的域名/dede/login.php才可以登录.通过尝试最终解决了问题,下面分享出来: 1.打开根目录da ...
- MyEclipse设置编码方式
1.windows->Preferences……打开"首选项"对话框,左侧导航树,导航到general->Workspace, 右侧Text file encoding ...
- ArcGIS Geodatabase版本控制机制的学习总结
本文是最近内部的一个学习的自我整理,只有关键信息,如果需要详细了解,请参阅ArcGIS帮助文档: http://resources.arcgis.com/zh-cn/help/main/10.1/in ...
- WebService SendTimeout 超时问题
System.TimeoutException: 请求通道在等待 00:01:00 以后答复时超时.增加传递给请求调用的超时值,或者增加绑定上的 SendTimeout 值.分配给此操作的时间可能是更 ...
- java之内部类(InnerClass)----非静态内部类、静态内部类、局部内部类、匿名内部类
提起java内裤类(innerClass)很多人不太熟悉,实际上类似的概念在c++里面也有,那就是嵌套类(Nested Class),关于这俩者的区别,在下文中会有对比.内部类从表面上看,就是在类中定 ...
- Twig模版语言入门
转自 :http://pengbotao.cn/twig-template-language.html Twig中有两种定界符{% ... %} 和 {{ ... }} , 前一种用来执行语句,比如f ...