http://poj.org/problem?id=2185   大概算是我学KMP简单题以来最废脑子的KMP题目了 , 当然细节并不是那么多 , 还是码起来很舒服的 , 题目中描写的平铺是那种瓷砖一样上下对齐的平铺 , 刚开始以为像地砖一样可以交错着铺 . . .  需要两次kmp..我用的是题解的方法写第一次kmp...这样找起来似乎更清晰. http://blog.sina.com.cn/s/blog_69c3f0410100tyjl.html 下面是代码 #include<cstdio>…
题目:http://poj.org/problem?id=2185 题意:就是要求一个字符矩阵的最小覆盖矩阵,可以在末尾不完全重合(即在末尾只要求最小覆盖矩阵的前缀覆盖剩余的尾部就行了) 分析: 先看一维的,对于一个一维字符串的最小覆盖子串首先肯定是它的一个前缀,而这个前缀的最小长度为n-next[n],证明在这里http://blog.csdn.net/fjsd155/article/details/6866991 然后发现这题就是二维的,于是可以考虑求出所有行的最小覆盖子串长度,而这些长度的…
Milking Grid Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 10084   Accepted: 4371 Description Every morning when they are milked, the Farmer John's cows form a rectangular grid that is R (1 <= R <= 10,000) rows by C (1 <= C <= 7…
Description Every morning when they are milked, the Farmer John's cows form a rectangular grid that is R (1 <= R <= 10,000) rows by C (1 <= C <= 75) columns. As we all know, Farmer John is quite the expert on cow behavior, and is currently wri…
                                                        Milking Grid Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 7153   Accepted: 3047 Description Every morning when they are milked, the Farmer John's cows form a rectangular grid tha…
Milking Grid Time Limit: 3000MS Memory Limit: 65536K Description Every morning when they are milked, the Farmer John's cows form a rectangular grid that is R (1 <= R <= 10,000) rows by C (1 <= C <= 75) columns. As we all know, Farmer John is q…
Milking Grid Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 8226   Accepted: 3549 Description Every morning when they are milked, the Farmer John's cows form a rectangular grid that is R (1 <= R <= 10,000) rows by C (1 <= C <= 75…
题目来源:id=2185" target="_blank">POJ 2185 Milking Grid 题意:至少要多少大的子矩阵 能够覆盖全图 比如例子 能够用一个AB 组成一个 ABABAB ABABAB 能够多出来 思路:每一行求出周期 总共n个 求这n个周期的最小公倍数 假设大于m 取m 每一列求出周期 总共m个求这个m个周期的最小公倍数 假设大于n取n 答案就是2个最小公倍数的积 #include <cstdio> #include <cst…
先对每行求出所有可能的循环节长度(不需要整除). 然后取在所有行中都出现了的,且最小的长度为宽. 然后将每一行看作字符,对所有行求next数组,将n-next[n](对这些行来说最小的循环节长度)作为长. 最后输出长乘宽即可. #include<cstdio> #include<cstring> using namespace std; bool can[10010][80]; char s[10010][80]; int next[80],n,m,wide,NEXT[10010]…
题目链接:http://poj.org/problem?id=2185 题目大意:求一个二维的字符串矩阵的最小覆盖子矩阵,即这个最小覆盖子矩阵在二维空间上不断翻倍后能覆盖原始矩阵. 题目分析:next函数的应用.需要枚举每一行每一列的字符串所对应的的 \(nxt[]\) 值,然后通过分析计算出最小的宽和最小的高. 具体分析 参考链接:https://blog.csdn.net/u013686535/article/details/52197467 一看这题,容易想出一种很直观的做法:求出每一行的…