比赛 暑假培训五 评测结果 AAAAAAAAAA
题目名称 找最佳通路 最终得分 100
用户昵称 Oo湼鞶oO 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-07-22 10:56:10
显示代码纯文本
{*******************************************}
{* Program Name:city                       *}
{* Input file:city.in                      *}
{* Output file:city.out                    *}
{* Date:2008.7.22                          *}
{* Programmer:Peng Bo                      *}
{*******************************************}
program citys;
type
  s1=array[1..50]of boolean;
  s2=array[1..50,1..50]of boolean;
var
  r:s2;
  c:s1;
  m:word;
  n,s,e,g:byte;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure input;
var
  f:text;
  a,b,i:byte;
begin
  assign(f,'city.in');
  reset(f);
  readln(f,n,m,s,e);
  for i:=1 to m do
  begin
    readln(f,a,b);
    r[a,b]:=true;
  end;
  close(f);
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure output;
var
  f:text;
begin
  assign(f,'city.out');
  rewrite(f);
  writeln(f,g);
  close(f);
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure main(a,f:integer);
var
  i,j:integer;
begin
  if (a=e)and(f<m) then
  g:=f;
  for i:=1 to n do
    if (r[a,i])and(not(c[i])) then
    begin
      c[i]:=true;
      main(i,f+1);
      c[i]:=false;
    end;
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
begin
  g:=255;
  input;
  main(s,1);
  output;
end.
{End.}