比赛 |
NOIP模拟赛by mzx Day1 |
评测结果 |
AAAAAAATTT |
题目名称 |
零食店 |
最终得分 |
70 |
用户昵称 |
doriko |
运行时间 |
3.324 s |
代码语言 |
Pascal |
内存使用 |
1.23 MiB |
提交时间 |
2016-10-19 21:17:03 |
显示代码纯文本
var x,y,z,i,num,m,n,q,st,xd,tl,ds,dw,next,ans,j:longint;
dl,last:array[0..100000]of longint;
f,dis,w:array[0..100]of longint;
rd:array[0..20000,1..4]of longint;
begin
assign(input,'snackstore.in');reset(input);
assign(output,'snackstore.out');rewrite(output);
readln(n,m,q);
for i:=1 to n do read(w[i]);
for i:=1 to m do
begin
read(x,y,z);
inc(num);
rd[num,1]:=x;rd[num,2]:=y;rd[num,3]:=z;rd[num,4]:=last[x];
last[x]:=num;
inc(num);
rd[num,1]:=y;rd[num,2]:=x;rd[num,3]:=z;rd[num,4]:=last[y];
last[y]:=num;
end;
for i:=1 to q do
begin
readln(st,xd,tl);
ans:=0;dl[1]:=st;
fillchar(dis,sizeof(dis),127);
ds:=1;dw:=1;f[st]:=1;dis[st]:=0;
while ds<=dw do
begin
next:=last[dl[ds]];
while next<>0 do
begin
if rd[next,3]+dis[dl[ds]]<=tl then
begin
f[rd[next,2]]:=1;
if w[rd[next,2]]<=xd then
if rd[next,3]+dis[dl[ds]]<=dis[rd[next,2]] then
begin
inc(dw);
dl[dw]:=rd[next,2];
dis[rd[next,2]]:=rd[next,3]+dis[dl[ds]];
end;
end;
next:=rd[next,4];
end;
inc(ds);
end;
f[st]:=0;
for j:=1 to n do if f[j]=1 then begin inc(ans);f[j]:=0;end;
writeln(ans);
end;
close(output);
end.