完全不会啊……

附一份题解:http://blog.sina.com.cn/s/blog_69c3f0410100tyjl.html

 var i,j,k,r,c,x:longint;
ch:array[..,..] of char;
s:string;
rr,cc:array[..] of boolean;
pre:array[..] of longint;
procedure init;
begin
readln(r,c);
for i:= to r do
begin
readln(s);
for j:= to c do ch[i,j]:=s[j];
end;
end;
procedure main;
begin
fillchar(rr,sizeof(rr),true);
fillchar(cc,sizeof(cc),true);
for x:= to r do
begin
pre[]:=;k:=;
for i:= to c do
begin
while (k<>) and (ch[x,k+]<>ch[x,i]) do k:=pre[k];
if ch[x,k+]=ch[x,i] then inc(k);
pre[i]:=k;
end;
k:=c;
for i:= to c do
if c-pre[k]<>i then cc[i]:=false else k:=pre[k];
end;
for x:= to c do
begin
pre[]:=;k:=;
for i:= to r do
begin
while (k<>) and (ch[k+,x]<>ch[i,x]) do k:=pre[k];
if ch[k+,x]=ch[i,x] then inc(k);
pre[i]:=k;
end;
k:=r;
for i:= to r do
if r-pre[k]<>i then rr[i]:=false else k:=pre[k];
end;
for i:= to r do if rr[i] then break;
for j:= to c do if cc[j] then break;
writeln(i*j);
end;
begin
init;
main;
end.

if c-pre[k]<>i then cc[i]:=false else k:=pre[k];

if r-pre[k]<>i then rr[i]:=false else k:=pre[k];

这两句话到底什么意思?

poj 2185 (KMP)的更多相关文章

  1. Oulipo POJ - 3461(kmp,求重叠匹配个数)

    Problem Description The French author Georges Perec (1936–1982) once wrote a book, La disparition, w ...

  2. POJ - 3461 (kmp)

    题目链接:http://poj.org/problem?id=3461 Oulipo Time Limit: 1000MS   Memory Limit: 65536K Total Submissio ...

  3. 剪花布条 HDU - 2087(kmp,求不重叠匹配个数)

    Problem Description 一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案.对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出几块小饰条来呢? Input 输入 ...

  4. POJ 1961 2406 (KMP,最小循环节,循环周期)

    关于KMP的最短循环节.循环周期,请戳: http://www.cnblogs.com/chenxiwenruo/p/3546457.html (KMP模板,最小循环节) POJ 2406  Powe ...

  5. poj 2406:Power Strings(KMP算法,next[]数组的理解)

    Power Strings Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 30069   Accepted: 12553 D ...

  6. POJ 2185 Milking Grid KMP循环节周期

    题目来源:id=2185" target="_blank">POJ 2185 Milking Grid 题意:至少要多少大的子矩阵 能够覆盖全图 比如例子 能够用一 ...

  7. Milking Grid POJ - 2185 || 最小覆盖子串

    Milking Grid POJ - 2185 最小覆盖子串: 最小覆盖子串(串尾多一小段时,用前缀覆盖)长度为n-next[n](n-pre[n]),n为串长. 当n%(n-next[n])==0时 ...

  8. HDU 3374 String Problem (KMP+最大最小表示)

    HDU 3374 String Problem (KMP+最大最小表示) String Problem Time Limit: 2000/1000 MS (Java/Others)    Memory ...

  9. Luogu 3375 【模板】KMP字符串匹配(KMP算法)

    Luogu 3375 [模板]KMP字符串匹配(KMP算法) Description 如题,给出两个字符串s1和s2,其中s2为s1的子串,求出s2在s1中所有出现的位置. 为了减少骗分的情况,接下来 ...

随机推荐

  1. php,javscript调用百地图度API实现标记

    最近一个项目需要用到地图的定位和标记功能,本来考虑使用google map API .但是在国内这个速度确实很慢,有时候加载到一半就出现错了,不过可以通过google agent 来解决在国内的访问速 ...

  2. c# 判断点是否在区域内 点在区域内 在多边形内 判断

    方法一 算法 : public int isLeft(Point P0, Point P1,Point P2)        {            int abc= ((P1.X - P0.X) ...

  3. 1020. Tree Traversals (序列建树)

    Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and i ...

  4. ios设备 分辨率(转)

    1 iOS设备的分辨率 iOS设备,目前最主要的有3种(Apple TV等不在此讨论),按分辨率分为两类 iPhone/iPod Touch 普屏分辨率    320像素 x 480像素 Retina ...

  5. ParentChildTest.java

    public class ParentChildTest { public static void main(String[] args) { Parent parent=new Parent(); ...

  6. 2001: [Hnoi2010]City 城市建设 - BZOJ

    DescriptionPS国是一个拥有诸多城市的大国,国王Louis为城市的交通建设可谓绞尽脑汁.Louis可以在某些城市之间修建道路,在不同的城市之间修建道路需要不同的花费.Louis希望建造最少的 ...

  7. Java连接redis的使用示例

    在多线程下使用Jedis 在不同的线程中使用相同的Jedis实例会发生奇怪的错误.但是创建太多的实现也不好因为这意味着会建立很多sokcet连接,也会导致奇怪的错误发生.单一Jedis实例不是线程安全 ...

  8. Visual C++ unicode and utf8 转换

    ATL宏: USES_CONVERSION; W2A A2W CString StringUtil::UTF8_to_UNICODE(const char *utf8_string, int leng ...

  9. POJ 3393 Lucky and Good Months by Gregorian Calendar

    http://poj.org/problem?id=3393 题意 : 对于这篇长长的英语阅读,表示无语无语再无语,花了好长时间,终于读完了.题目中规定每周的周六日为假日,其他为工作日,若是一个月的第 ...

  10. HDU4607+BFS

    /* bfs+求树的直径 关键:if k<=maxs+1 直接输出k-1: else: k肯定的是包括最长路.先从最长路的起点出发,再走分支,最后到达最长路的终点. 因此是2*(k-(maxs+ ...