
KMP~
xuanweiace
一个热爱算法竞赛的弱校ACMer路过。青大本,浙大硕,方向后端开发,菜鸡一枚,奋斗ing...
展开
-
【HDU - 2087】 剪花布条(直接模拟 or KMP)
题干: 一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案。对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出几块小饰条来呢? Input输入中含有一些数据,分别是成对出现的花布条和小饰条,其布条都是用可见ASCII字符表示的,可见的ASCII字符有多少个,布条的花纹也有多少种花样。花纹条和小饰条不会超过1000个字符长。如果遇见#字符,则不再进行工作。 Outpu...原创 2018-07-14 22:59:53 · 331 阅读 · 0 评论 -
【POJ - 1961】Period(KMP,循环节问题)
题干: For each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126, inclusive), we want to know whether the prefix is a periodic string. That is, for each ...原创 2019-01-30 23:36:48 · 240 阅读 · 0 评论 -
【HDU - 3746 】Cyclic Nacklace (KMP,最小循环节问题)
题干: CC always becomes very depressed at the end of this month, he has checked his credit card yesterday, without any surprise, there are only 99.9 yuan left. he is too distressed and thinking about h...原创 2019-01-30 23:29:32 · 245 阅读 · 0 评论 -
【POJ - 2752】Seek the Name, Seek the Fame (KMP,公共前缀后缀长度及个数)
题干: The little cat is so famous, that many couples tramp over hill and dale to Byteland, and asked the little cat to give names to their newly-born babies. They seek the name, and at the same time se...原创 2019-01-30 23:26:07 · 305 阅读 · 0 评论 -
【HDU - 1867 】A + B for you again(KMP,next数组应用)
题干: Generally speaking, there are a lot of problems about strings processing. Now you encounter another such problem. If you get two strings, such as “asdf” and “sdfg”, the result of the addition bet...原创 2018-10-30 17:17:05 · 175 阅读 · 0 评论 -
【 HDU - 2594 】Simpsons’ Hidden Talents(KMP应用,求最长前缀后缀公共子串)
题干: Homer: Marge, I just figured out a way to discover some of the talents we weren’t aware we had. Marge: Yeah, what is it? Homer: Take me for example. I want to find out if I have a talent in pol...原创 2018-10-23 20:17:57 · 342 阅读 · 0 评论 -
【POJ - 2406】Power Strings (KMP,最小循环节)
题干: Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concatenation as multiplication, exponentiation by a...原创 2018-10-23 17:08:03 · 241 阅读 · 0 评论 -
KMP 常用模板
写在前面: 代码中有的是i,j,有的是j,k,总之不唯一啊@!!!这个一定要弄清楚!!!我没有统一。。 从0开始的字符串,加速版。 void getnext() { next[0]=-1; int k=-1,j=0; while(j<len2-1) { if(k==-1||str2[k]==str2[j]) { k++; j++; if(st...原创 2018-10-22 22:07:21 · 276 阅读 · 0 评论 -
【HDU - 5918 】Sequence I (数组(字符串)匹配问题,可选KMP)
题干: Mr. Frog has two sequences a1,a2,⋯,ana1,a2,⋯,an and b1,b2,⋯,bmb1,b2,⋯,bm and a number p. He wants to know the number of positions q such that sequence b1,b2,⋯,bmb1,b2,⋯,bm is exactly the sequence...原创 2018-09-05 20:27:18 · 460 阅读 · 0 评论 -
【牛客OI周赛7-普及组ABCD 非官方题解】暴力,二分,KMP,尺取(STL或Hash)
A: 链接:https://ac.nowcoder.com/acm/contest/372/A 来源:牛客网 某天,一只可爱的肥橘喵在路上走,突然遇到了一个怪人,那怪人自称PM6,“小肥喵,这里有一道水题,答对了我就请你吃狗肉,答错了你就请我吃猫肉!” 喵咪瑟瑟发抖:“QAQ什么题?” PM6道:“给你坐标轴上的N个点,求出对于每个点,有多少个点的 X 坐标和 Y 坐标都大于它。” ...原创 2019-02-24 09:41:29 · 643 阅读 · 0 评论