比赛 NOIP2008集训模拟5 评测结果 WWWWWWWWWA
题目名称 数星星 最终得分 10
用户昵称 卐祭司卐 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-11-14 10:53:08
显示代码纯文本
program mengyalan;
const
  maxn=10000;
  f:array[1..8,1..2] of integer
    =((-1,-1),(-1,0),(-1,1),(0,-1),(0,1),(1,-1),(1,0),(1,1));
var
  i,j,x,y,max:longint;
  n,k:integer;
  way:byte;
  fi,fo:text;
  s:array[-1..maxn+1,-1..maxn+1] of boolean;
  p:array[1..maxn,1..2] of integer;
procedure fway(xx,yy,ff:integer);
begin
  if s[(xx+f[ff,1]),(yy+f[ff,2])] then way:=1
  else way:=0;
end;

begin
  assign(fi,'stars.in');
  assign(fo,'stars.out');
  reset(fi);
  rewrite(fo);
  fillchar(s,sizeof(s),false);
  readln(fi,n);
  for i:=1 to n do
   begin
    readln(fi,p[i,1],p[i,2]);
    s[p[i,1],p[i,2]]:=true;
   end;
   max:=1;
  for i:=1 to n do
  for j:=1 to 8 do
  if (p[i,1]+f[j,1]>=0)and(p[i,2]+f[j,2]>=0)
  and(p[i,1]+f[j,1]<=maxn)and(p[i,2]+f[j,2]<=maxn) then
  begin
   k:=1;
   x:=p[i,1];y:=p[i,2];
   repeat
    fway(x,y,j);
    k:=k+way;
    if way=1 then
    begin
     x:=x+f[j,1];
     y:=y+f[j,2];
    end;
   until way=0;
   if k>max then max:=k;
  end;
  write(fo,max);
  close(fi);
  close(fo);
end.