hdu 1238 Substrings(kmp+暴力枚举)】的更多相关文章

Problem Description You are given a number of case-sensitive strings of alphabetic characters, find the largest string X, such that either X, or its inverse can be found as a substring of any of the given strings.   Input The first line of the input…
abs Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Problem Description Given a number x, ask positive integer y≥2, that satisfy the following conditions:1. The absolute value of y - x is minimal2. To prime facto…
Safecracker Problem Description === Op tech briefing, 2002/11/02 06:42 CST ===  "The item is locked in a Klein safe behind a painting in the second-floor library. Klein safes are extremely rare; most of them, along with Klein and his factory, were de…
题意:求n个串的字典序最小的最长公共子串. 解法:枚举第一个串的子串,与剩下的n-1个串KMP匹配,判断是否有这样的公共子串.从大长度开始枚举,找到了就break挺快的.而且KMP的作用就是匹配子串,近乎O(n)的速度,很快. P.S.对于字符串要仔细!!! #include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> using namespace std; ; int n;…
题意:给你多个字符串,问你这几个字符串的最长公共子串是哪个,如果有多个,输出字典序最大的那个,如果最长的公共子串长度小于3,输出一个奇怪的东西: 解题思路:首先看数据,数据不大,开始简单快乐的暴力之路,因为是公共的子串,所以我们随便找一个原串,把它的子串全部循环一遍,然后所有的子串都去和剩余的原串跑一遍kmp,如果匹配没啥问题,那么这个子串是剩余所有原串的公共子串,然后更新答案: 代码: #include<iostream> #include<algorithm> #include…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5510 思路: 一开始直接用KMP莽了发,超时了,后面发现如果前面的字符串被后面的字符串包含,那么我们就不需要用前面的字符串去比较了,把他标记掉就好了. 实现代码: #include<iostream> #include<algorithm> #include<cstring> #include<cstdio> using namespace std; ][];…
第一次写计算几何,ac,感动. 不过感觉自己的代码还可以美化一下. 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=5128 题意: 在一个坐标系中,有n个点,从中找到两个互不touch,互不cross的两个矩形(边要和坐标轴平行),使得面积最大. 思路: 枚举每个点,n的四次方,这题有个坑点是“回型矩阵”,是真的坑,然后discuss区里说的十字形矩阵是骗人的. 每次对枚举的四个点进行check,如果两个矩阵的四个点相互不在对方的矩阵中,那么这组就是…
题意:给定一个序列,要求从这个序列中挑出k个数字,使得n%a1%a2%a3....=0(顺序随你意).求k的最小值. 思路:排个序,从大的数开始模起,这是因为小的模完还能模大的么? 每个元素可以选,也可以不选,两种情况.递归穷举每个可能性,O(2n). //#include <bits/stdc++.h> #include <cstdio> #include <cstring> #include <map> #include <algorithm>…
http://acm.hdu.edu.cn/showproblem.php?pid=1238 Substrings Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1238 Description You are given a number of case-sensitive strings of alphabetic characte…
题目链接:hdu_2328_Corporate Identity 题意: 给你n个串,让你找这n个串的最大公共子串 题解: 串比较小,暴力枚举第一个的子串,然后KMP判断是否可行 #include<cstdio> #include<cstring> #define F(i,a,b) for(int i=a;i<=b;i++) ; ],ans,l,r,cnt; ][N]; int KMP(int n,char*a,int m,char*b){ int i,j; ]=j=-,i=…