比赛 20100419 评测结果 AAAAAAAAAA
题目名称 城市规划 最终得分 100
用户昵称 ybh 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-04-19 11:29:46
显示代码纯文本
  1. program ChengShiGuiHua;
  2. var
  3. way:array[0..100,0..100] of longint;
  4. path:array[0..100,0..100] of boolean;
  5. n,i,j,r,k,sum:longint;
  6.  
  7. begin
  8. assign(input,'cityroad.in');
  9. reset(input);
  10. assign(output,'cityroad.out');
  11. rewrite(output);
  12. readln(n);
  13. for i:=1 to n do
  14. for j:=1 to n do
  15. begin
  16. read(r);
  17. if r>=1 then
  18. begin
  19. way[i,j]:=r;
  20. path[i,j]:=true;
  21. end
  22. else
  23. begin
  24. way[i,j]:=10000000;
  25. path[i,j]:=false;
  26. end
  27. end;
  28. for k:=1 to n do
  29. for i:=1 to n do
  30. for j:=1 to n do
  31. if i<>j then
  32. if way[i,k]+way[k,j]<=way[i,j] then
  33. begin
  34. way[i,j]:=way[i,k]+way[k,j];
  35. if path[i,j] then
  36. begin
  37. path[i,j]:=false;
  38. path[j,i]:=false;
  39. end
  40. end;
  41. sum:=0;
  42. for i:=1 to n-1 do
  43. for j:=i+1 to n do
  44. if path[i,j]=true then
  45. sum:=sum+way[i,j];
  46. writeln(sum);
  47. for i:=1 to n do
  48. begin
  49. for j:=1 to n do
  50. if path[i,j]
  51. then write(1,' ')
  52. else write(0,' ');
  53. writeln;
  54. end;
  55. close(input);
  56. close(output);
  57. end.