记录编号 13531 评测结果 EEEEEEEEEE
题目名称 [NOI 2007]社交网络 最终得分 0
用户昵称 Gravatarmaxiem 是否通过 未通过
代码语言 Pascal 运行时间 0.002 s
提交时间 2009-10-06 12:03:49 内存使用 0.32 MiB
显示代码纯文本
  1. program network;
  2. var
  3. path,dis:array [1..100,1..100] of int64;
  4. ans:array [1..100] of extended;
  5. i,n,m,a,b,v:longint;
  6. begin
  7. fillchar (ans,sizeof(ans),0);
  8. assign (input,'network.in');
  9. reset (input);
  10. readln (n,m);
  11. for a:=1 to n do for b:=1 to n do begin
  12. dis[a,b]:=10000000000;
  13. path[a,b]:=1;
  14. end;
  15. for i:=1 to m do begin
  16. readln (a,b,v);
  17. dis[a,b]:=v;
  18. dis[b,a]:=v;
  19. end;
  20. close (input);
  21. assign (output,'network.out');
  22. rewrite (output);
  23. for i:=1 to n do for a:=1 to n do for b:=1 to n do if (i<>a) and (i<>b) and (a<>b) then
  24. if dis[a,b]>dis[a,i]+dis[i,b] then begin
  25. dis[a,b]:=dis[a,i]+dis[i,b];
  26. path[a,b]:=path[a,i]*path[i,b];
  27. end
  28. else if dis[a,b]=dis[a,i]+dis[i,b] then path[a,b]:=path[a,b]+path[a,i]*path[i,b];
  29. for i:=1 to n do for a:=1 to n do for b:=1 to n do
  30. if (a<>i) and (b<>i) and (a<>b) and (dis[a,i]+dis[i,b]=dis[a,b]) and (path[a,b]<>0) then
  31. ans[i]:=ans[i]+path[a,i]*path[i,b]/path[a,b];
  32. for i:=1 to n do writeln (ans[i]:0:3);
  33. close (output);
  34. end.