记录编号 | 12189 | 评测结果 | AAAAAAAAAA | ||
---|---|---|---|---|---|
题目名称 | 找最佳通路 | 最终得分 | 100 | ||
用户昵称 | 是否通过 | 通过 | |||
代码语言 | Pascal | 运行时间 | 0.025 s | ||
提交时间 | 2009-09-05 16:48:39 | 内存使用 | 0.13 MiB | ||
Program city; Type abc=record data:integer; dep:integer; end; sc=array [1..100,1..100] of integer; sc1=array [1..100] of abc; sc2=array [1..100] of boolean; Var s:sc; dui:sc1; panduan:sc2; head,tail:integer; i,j:integer; n,m,c,e,a,b:integer; Begin assign(input,'city.in'); assign(output,'city.out'); reset(input); rewrite(output); readln(n,m,c,e); for i:=1 to n do for j:=1 to n do s[i,j]:=0; for i:=1 to m do begin readln(a,b); s[a,b]:=1; end; head:=0; tail:=0; dui[1].data:=c; dui[1].dep:=1; for i:=1 to n do panduan[i]:=true; panduan[c]:=false; head:=0; tail:=1; repeat head:=head+1; for i:=1 to n do begin if s[dui[head].data,i]=1 then begin if panduan[i]=true then begin tail:=tail+1; dui[tail].data:=i; dui[tail].dep:=dui[head].dep+1; if dui[tail].data=e then begin writeln(dui[tail].dep); close(input); close(output); halt; end; panduan[i]:=false; end; end; end; until(head=tail); End.