完全不会啊……

附一份题解: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. Think PHP 提示验证码输入错误

    最近遇到一个项目中用的是Thinkphp这个框架开发的,其中在登录这块有验证码这个功能,其实这个功能是TP自带的,其中主要方法是buildImageVerify,位于ThinkPHP\Extend\L ...

  2. maven项目转eclipse工程的命令:eclipse.bat

    call mvn clean:clean call mvn eclipse:eclipse -DdownloadSources=true @pause 复制以上内容,保存为eclipse.bat 以后 ...

  3. SPOJ 4487 Splay 基本操作

    插入操作,删除操作和置换操作都是单点的,所以不需要lazy标记.这个很简单,都是两次RotateTo,一次Splay操作就搞定. 求最大连续字段和的操作和线段树的题目类似,只需要保存最左边的连续最大字 ...

  4. Tomcat 搭配 Nginx 还是 Apache 呢?

    Apache .Tomcat.Nginx的区别, 哪个与Tomcat搭配效率高? 一. 定义: 1. Apache Apache HTTP服务器是一个模块化的服务器,可以运行在几乎所有广泛使用的计算机 ...

  5. 远程登陆MS azure Linux 虚拟机

    http://blogs.technet.com/b/uktechnet/archive/2013/11/12/running-a-remote-desktop-on-a-windows-azure- ...

  6. 18:字符串-char型字符串

    1 什么是字符串? 字符串是以空字符(\)结尾的字符数组.空字符的assii码为:0, 空格的ascii码为322 \0的作用'\0'是一个空字符标志,它的ASSII码为0,C++有好多处理字符串的函 ...

  7. MySQL查询本周、上周、本月、上个月份数据的sql代码(转)

    感谢:http://www.jb51.net/article/32277.htm ----------------------------------------------------------- ...

  8. JS中如何定义全局变量

    三种方法 1.在js的function外定义一个变量 var name='测试'; function XX(){        alert(name); } 2.不使用var,直接给定义变量,隐式的声 ...

  9. 【数位DP】bzoj1026: [SCOI2009]windy数

    1026: [SCOI2009]windy数 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 4163  Solved: 1864[Submit][Sta ...

  10. WCF服务的创建和发布到IIS

    一. WCF服务的创建 有两种创建方式: 1.WCF服务库 2.WCF服务应用程序 如下图所示: 这里选择WCF服务库.注意事项: 1.WCF服务库是一个类库项目,这里选择.net 3.5版本(版本高 ...