fork(10) download
  1. const INP = 'input.txt';
  2. var
  3. f : text;
  4. n, i, j, a, b, sum : integer;
  5. len, s, p : array[1..1000] of integer;
  6. G : array[1..100,1..100] of integer;
  7. BEGIN
  8.  
  9. {doc du lieu tu tep}
  10. assign(f, INP);
  11. reset(f);
  12.  
  13. readln(f, n, a, b);
  14. writeln(n, ' ', a, ' ', b);
  15. sum :=0;
  16. for i:=1 to n do
  17. begin
  18. for j:=1 to n do
  19. begin
  20. read(f, G[i, j]);
  21. sum := sum + G[i, j];
  22. end;
  23. readln(f);
  24. end;
  25.  
  26. {dat vo cung cho tat ca cap dinh khong co duong di}
  27. for i:=1 to n do
  28. for j:=1 to n do
  29. if (i <> j) and (G[i, j] = 0) then
  30. G[i, j] := sum;
  31.  
  32. for i:=1 to n do
  33. begin
  34. len[i] := sum; {khoi tao do dai tu a toi moi dinh la vo cung}
  35. s[i] := 0; {danh sach cac diem da xet}
  36. p[i] := a; {diem bat dau cua moi dinh la a}
  37. end; {do dai tu a den a la 0}
  38. len[a] := 0;
  39.  
  40. while (s[b] = 0) do {trong khi dinh b chua duoc duyet}
  41. begin
  42. for i:=1 to n do {tim 1 dinh chua xet ma co the di tu a den no}
  43. begin
  44. if (s[i]=0) and (len[i] < sum) then
  45. begin
  46. break;
  47. end;
  48. end;
  49. if i>n then {khong tim thay dinh nao, dung lai}
  50. begin
  51. break;
  52. end;
  53.  
  54. for j:=1 to n do {tim dinh ma duong di tu a den no la nho nhat}
  55. if (s[j] = 0) and (len[i] > len[j]) then i := j;
  56.  
  57. s[i] := 1; {danh dau da duyet}
  58.  
  59. for j:=0 to n do {tinh lai duong di den cac dinh chua xet}
  60. if (s[j] = 0) and (len[i] + G[i, j] < len[j]) then
  61. begin
  62. len[j] := len[i] + G[i, j];
  63. p[j] := i;
  64. end;
  65. end;
  66.  
  67. i := b;
  68. while(i <>a) do
  69. begin
  70. write(i, ' <-- ');
  71. i := p[i];
  72. end;
  73. writeln(a);
  74. END.
Runtime error #stdin #stdout 0s 300KB
stdin
Standard input is empty
stdout
Runtime error 2 at $080480CF
  $080480CF
  $08063C73