比赛 noip_6 评测结果 AAAAATTTTT
题目名称 词链 最终得分 50
用户昵称 MayLava 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-10-08 19:30:56
显示代码纯文本
program MayLava;
var
 s:array[0..10000]of string;
 a:array[0..10000]of longint;
 n:longint;
procedure start;
 var
  f:text;
  i:longint;
 begin
  assign(f,'link.in');
  reset(f);
  readln(f,n);
  for i:=1 to n do begin
   readln(f,s[i]);
   a[i]:=1;
  end;
  close(f);
 end;
procedure main;
 var
  i,j,max:longint;
 begin
  for i:=2 to n do begin
   max:=0;
   for j:=i-1 downto 1 do
    if (pos(s[j],s[i])=1) and (a[j]>max) then max:=a[j];
   a[i]:=a[i]+max;
  end;
 end;
procedure print;
 var
  f:text;
  i,max:longint;
 begin
  max:=0;
  for i:=1 to n do
   if a[i]>max then max:=a[i];
  assign(f,'link.out');
  rewrite(f);
  writeln(f,max);
  close(f);
 end;
BEGIN
  start;
  main;
  print;
END.