记录编号 326945 评测结果 WWWWWWWTTT
题目名称 零食店 最终得分 0
用户昵称 Gravatar燕哥到此一游 是否通过 未通过
代码语言 Pascal 运行时间 4.770 s
提交时间 2016-10-21 17:51:37 内存使用 0.28 MiB
显示代码纯文本
program fuckyoutwice;
const
  maxn=10000;
var
  w,dist:array[1..10000] of longint;
  a:array[1..100,1..100] of longint;
  i,j,ans,n,m,o,s,c,d,x0,y0,l:longint;
  fin,fout:text;
procedure spfa;
  var
  q:array[1..maxn] of integer;
  v:array[1..maxn] of boolean;
{  a:array[1..maxn,1..maxn] of integer;}
  h,t,i,x,j:integer;
  begin
  for i:=1 to n do
    dist[i]:=maxint;
  fillchar(q,sizeof(q),0);
  fillchar(v,sizeof(v),false);
{  fillchar(b,sizeof(b),0); }
  t:=1;
  h:=0;
  q[1]:=s;
  v[s]:=true;
  dist[s]:=0;
  while h<t do
    begin
      h:=(h+1) ;
      x:=q[h];
      v[x]:=false;
      for i:=1 to n do  {
        if b[i]>n-1 then
          begin
            writeln('error!');
            exit;
          end
        else }
          if (w[i]<=c) and (dist[x]+a[x,i]<dist[i]) then
            begin
               dist[i]:=dist[x]+a[x,i];
               if not (v[i]) then
                  begin
                    t:=(t+1) ;
                    q[t]:=i; v[i]:=true;
                 {   b[i]:=b[i]+1; }
                  end;
            end;
      {v[i]:=false;}
    end;
end;

begin
  assign(fin,'snackstore.in');
  assign(fout,'snackstore.out');
  reset(fin);
  rewrite(fout);
  readln(fin,n,m,o);
  for i:=1 to n do
    read(fin,w[i]);
  for i:=1 to m do
    begin
      readln(fin,x0,y0,l);
      a[x0,y0]:=l;
      a[y0,x0]:=l;
    end;
  for i:=1 to o do
    begin
      readln(fin,s,c,d);
      spfa;
      ans:=1;            {for j:=1 to n do write(dist[j],','); writeln;  }
      for j:=1 to n do
        if dist[j]<=d
        then ans:=ans+1;
      writeln(fout,ans);
    end;
  close(fin);
  close(fout);
end.