比赛 noip_6 评测结果 AAAAAAAAAA
题目名称 词链 最终得分 100
用户昵称 dingding 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-10-08 21:30:38
显示代码纯文本
program ds;
var
   s:array[1..10000] of string;
   f:array[1..10000] of string;
   n,i,j,p,ans:longint;
   temp,temp1:string;
procedure chushi;
var input:text;
begin
   assign(input,'link.in');
   reset(input);
   readln(input,n);
   for i:=1 to n do
   readln(input,s[i]);
   close(input);
end;
procedure shuchu;
var output:text;
begin
   assign(output,'link.out');
   rewrite(output);
   writeln(output,ans);
   close(output);
end;
function max(a,b:longint):longint;
begin
   if a>b then exit(a);
   exit(b);
end;
begin
   chushi;
   f[1]:=s[1];p:=1;
   for i:=2 to n do
   begin
   temp:=copy(s[i],1,length(f[p]));
   if temp=f[p] then
   begin
   inc(p);
   ans:=max(ans,p);
   f[p]:=s[i];
   end
   else
   begin
   repeat
   temp1:=copy(s[i],1,length(f[p-1]));
   if (temp1=f[p-1]) then
   begin
   f[p]:=s[i];
   break;
   end;
   dec(p);
   if p=1 then
   begin
   f[p]:=s[i];
   break;
   end;
   until 1<>1;
   end;
   end;
   shuchu;
end.