记录编号 5513 评测结果 AAAAAAAAAA
题目名称 词链 最终得分 100
用户昵称 Gravatarname:弓虽 是否通过 通过
代码语言 Pascal 运行时间 0.511 s
提交时间 2008-10-27 11:06:13 内存使用 48.98 MiB
显示代码纯文本
program link(input,output);   
 var  
  i,j,k:longint;   
  flag:boolean;   
  n,ans,dep:longint;   
   a:array [1..100000] of string;   
   b:array [1..100000] of string;
c:array [1..10000] of longint;   
function panduan(s1,s2:string):boolean;   
 var  
  i,j,k,l1,l2:longint;   
  judge:boolean;   
begin  
 l1:=length(s1);   
 l2:=length(s2);   
  if l1>=l2 then panduan:=false  
   else  
    begin  
    i:=1;   
    judge:=true;   
    while judge and (i<=l1) do  
     begin  
      if s1[i]<>s2[i] then judge:=false  
       else i:=i+1;   
      end;   
     panduan:=judge;   
    end;   
   end;   
begin  
 assign(input,'link.in');   
 assign(output,'link.out');   
 reset(input);   
 rewrite(output);   
 readln(n);   
  for i:=1 to n do readln(a[i]);   
 ans:=0;   
 dep:=1;   
 fillchar(b,sizeof(b),0);   
 b[1]:=a[1];   
  for i:= 2 to n do begin  
   flag:=true;   
    while (flag=true) do begin  
      if (panduan(b[dep],a[i])) then  
       begin  
        dep:=dep+1;   
        b[dep]:=a[i];   
        flag:=false;   
       end  
        else begin  
         if dep>ans then ans:=dep;   
          dep:=dep-1;   
         end;   
        end;   
       end;   
     if dep>ans then ans:=dep;   
    writeln(ans);   
   close(input);   
   close(output);   
  end.