记录编号 1768 评测结果 AAAAAAAAAA
题目名称 找最佳通路 最终得分 100
用户昵称 GravatarOo湼鞶oO 是否通过 通过
代码语言 Pascal 运行时间 128.000 s
提交时间 2008-09-08 19:00:19 内存使用 0.00 MiB
显示代码纯文本
{*******************************************}
{* 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;{input}
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure output;
var
  f:text;
begin
  assign(f,'city.out');
  rewrite(f);
  writeln(f,g);
  close(f);
end;{output}
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
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;{main}
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
begin
  g:=255;
  input;
  main(s,1);
  output;
end.