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的更多相关文章

  1. POJ 3461 Oulipo(乌力波)

    POJ 3461 Oulipo(乌力波) Time Limit: 1000MS   Memory Limit: 65536K [Description] [题目描述] The French autho ...

  2. 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 ...

  3. POJ 3461 Oulipo(字符串hash)

    题目链接 字符串hash判断字符串是否相等. code #include<cstdio> #include<algorithm> #include<cstring> ...

  4. POJ 3461 Oulipo

      E - Oulipo Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit ...

  5. POJ 3461 Oulipo[附KMP算法详细流程讲解]

      E - Oulipo Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit ...

  6. POJ 3461 Oulipo 【KMP统计子串数】

    传送门:http://poj.org/problem?id=3461 Oulipo Time Limit: 1000MS   Memory Limit: 65536K Total Submission ...

  7. POJ 3461 Oulipo(模式串在主串中出现的次数)

    题目链接:http://poj.org/problem?id=3461 题意:给你两个字符串word和text,求出word在text中出现的次数 思路:kmp算法的简单应用,遍历一遍text字符串即 ...

  8. HDU 1686 Oulipo , 同 POJ 3461 Oulipo (字符串匹配,KMP)

    HDU题目 POJ题目 求目标串s中包含多少个模式串p KMP算法,必须好好利用next数组,, (kmp解析)——可参考 海子的博客  KMP算法 //写法一: #include<string ...

  9. poj 3461 Oulipo(KMP模板题)

    Oulipo Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 36903   Accepted: 14898 Descript ...

随机推荐

  1. 直接使用提交过来的类来更新字段EntityState.Modified并过滤null值的方法

    public T Update<T>(T entity) where T : ModelBase { var set = this.Set<T>(); set.Attach(e ...

  2. 利用Aspose文档转图片

    通过使用Aspose您可以轻松的将您的文档转换成真正的图片格式,最好的保证您的内容将实际可见,与其他格式相比,它并不存在查看工具的安装问题. 准备工作: 1:下载Aspose组件包:http://do ...

  3. ./adb: cannot execute binary file:

    问题描述: 在32位ubuntu(12.04)上下载了最新的android SDK,使用SDK manager 下载ADB之后发现,无法运行ADB命令,排除权限问题,在网上搜到答案: http://a ...

  4. JS回到顶部代码小记

    HTML: <div id="goTop"> <a href="#top"><img src="~/Content/th ...

  5. CvMat 矩阵的使用方法和简单程序

    一:CvMat* cvInitMatHeader( CvMat* mat, int rows, int cols, int type,void* data=NULL, int step=CV_AUTO ...

  6. CSS - toggle collapse 类似bootstrap的展开效果

    问题:toggle collapse 类似bootstrap的展开效果(展开一个关闭另一个) Demo:http://jsfiddle.net/JSDavi/L47vscw4/ 方案:使用transi ...

  7. C primer plus 练习题 第五章

    1. #include <stdio.h> #define MINU 60 int main() { int minute, hour, m; printf("请输入分钟:&qu ...

  8. Ranorex 5 发布,支持SAP、Oracle Forms、MS Dynamics等

    Ranorex 5 发布,支持SAP.Oracle Forms.MS Dynamics等 http://blog.csdn.net/testing_is_believing/article/detai ...

  9. 说说lambda表达式与表达式树(未完)

    Lambda表达式可以转换成为代码(委托)或者数据(表达式树).若将其赋值给委托,则Lambda表达式将转换为IL代码:如果赋值给 Expression<TDelegate>,则构造出一颗 ...

  10. MAC 入门

    1.安装java jdk eclipse 后发现运行不了,原因是JAVA_HOME 没有设置,真操蛋 export JAVA_HOME=`/usr/libexec/java_home` 2.安装bre ...