比赛 20120710 评测结果 AWEEW
题目名称 RCDH外星人 最终得分 20
用户昵称 fuhao 运行时间 0.019 s
代码语言 Pascal 内存使用 7.81 MiB
提交时间 2012-07-10 11:38:48
显示代码纯文本
program et;
const maxn=1000; maxr=11;
var
 n,m,i,j,x,y,ans,z,k,l:longint;
 a,w:array[0..maxn,0..maxn] of longint;
 min:array[0..maxr] of longint;
begin
 assign(input,'et.in'); reset(input);
 assign(output,'et.out'); rewrite(output);
 readln(n,m);
 for i:=1 to n do
  begin
   read(x);
   inc(a[x,0]); a[x,a[x,0]]:=i;
  end;
 fillchar(w,sizeof(w),$7f div 2);
 for i:=1 to m do
  begin
   read(x,y,z);
   w[x,y]:=z;
   w[y,x]:=z;
  end;
 for k:=1 to n do
  for i:=1 to n do
   for j:=1 to n do
    if w[i,j]>w[i,k]+w[k,j] then
     w[i,j]:=w[i,k]+w[k,j];
 for i:=1 to n do
  begin
   fillchar(min,sizeof(min),$7f div 2);
   for j:=10 downto 1 do
     for l:=1 to a[j,0] do
      if w[i,a[j,l]]<min[j] then
       min[j]:=w[i,a[j,l]];
   for j:=10 downto 1 do
    if min[j]<min[j+1] then
     for l:=1 to a[j,0] do
      if w[i,a[j,l]]=min[j] then
       ans:=ans+1;
  end;
 writeln(ans+n-1);
 close(input); close(output);
end.