hdu-4468-Spy-KMP+贪心】的更多相关文章

Description “Be subtle! Be subtle! And use your spies for every kind of business. ”― Sun Tzu“A spy with insufficient ability really sucks”― An anonymous general who lost the warYou, a general, following Sun Tzu’s instruction, make heavy use of spies…
出的超级好的一道题.至于好在哪里,请思考题目: 题意抽象出来为给定一个字符串r,找出它的一个最短后缀s,使得这个r可以被 s的某前缀+s的某前缀+......+s的某前缀+s本身构造出来. 具体题目描述如下: "Be subtle! Be subtle! And use your spies for every kind of business. " - Sun Tzu "A spy with insufficient ability really sucks" -…
HDU 4442 Physical Examination(贪心) 题目链接http://acm.split.hdu.edu.cn/showproblem.php?pid=4442 Description WANGPENG is a freshman. He is requested to have a physical examination when entering the university. Now WANGPENG arrives at the hospital. Er-.. Th…
题目链接 题目都看不懂,做毛线...看懂了之后就是kmp出,所有的匹配区间,然后DP可以写,贪心也可以做把,DP应该需要优化一下,直接贪,也应该对的,经典贪心问题. #include<iostream> #include<cstring> #include<cstdio> #include<cmath> #include<algorithm> using namespace std; ],s2[]; ],o[]; ]; ]; int judge(…
1.HDU 2087 2.题意:一个主串,一个子串,求子串在主串里出现了几次. 3.总结:看了题解,还是不太懂.. //#include<iostream>#include<cmath>#include<queue>#include<algorithm> //不明白为什么加上这些头文件就Compilation Error #include<cstring> #include<cstdio> using namespace std; #…
http://acm.hdu.edu.cn/showproblem.php?pid=1711 首次接触KMP,自己都不是特别理解.在网上百度看了好几个帖子之后,对KMP也有了初步的理解. #include <stdio.h> ], b[], next[]; void getnext( int n) { , j=-; next[]=-; while(i<n) { || b[i]==b[j]) next[++i]=++j; else j=next[j]; } } int KMP(int m,…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1686 分析:典型的KMP算法,统计字符串匹配的次数. 用Next数组压缩时间复杂度,要做一些修改. /*Oulipo Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5769 Accepted Submission(s): 2322 Proble…
Danganronpa 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5835 Description Chisa Yukizome works as a teacher in the school. She prepares many gifts, which consist of n kinds with a[i] quantities of each kind, for her students and wants to hold a cl…
Ball 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5821 Description ZZX has a sequence of boxes numbered 1,2,...,n. Each box can contain at most one ball. You are given the initial configuration of the balls. For 1≤i≤n, if the i-th box is empty the…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4763 题目大意:给定一串字符,从中找出符合“EAEBE”格式的E的最大字符数.AB可以是任意数量的任意字符(a-z). Sample Input 5 xy abc aaa aaaaba aaxoaaaaa   Sample Output 0 0 1 1 2 分析:首先枚举判断开始和结尾是否满足作为E,再KMP计算中间是否存在E 代码如下: #include<cstdio> #include<…