讨论 / rpnoj398 求解答
余洋go 2013-10-28 04:46:00
点我顶贴 收藏 删除
题目:Mato完整版学体育

状态: Unaccepted

测评机: Xeost[5]

得分: 80分

提交日期: 2012-10-4 16:54:00

有效耗时: 657毫秒

测试结果1: 通过本测试点|有效耗时188ms

测试结果2: 通过本测试点|有效耗时156ms

测试结果3: 通过本测试点|有效耗时156ms

测试结果4: 通过本测试点|有效耗时157ms

测试结果5: 测试结果错误.错误结果为:251224144346

escape

正确结果应为:160132265414

escape

type

pnode=^tnode;

tnode=record

d,q:longint;

next:pnode;

end;

var

n,m:longint;

t:int64;

dist:array[0..100000] of longint;

f:array[0..1000000] of longint;

v:array[0..100000] of boolean;

dian:array[0..100000] of pnode;

procedure init;

begin

end;

procedure terminate;

begin

halt;

end;

procedure insert(a,b,c:longint);

var

p:pnode;

begin

new(p);

p^.d:=b;

p^.q:=c;

p^.next:=dian[a];

dian[a]:=p;

end;

function flag(a,b,c:longint):boolean;

var

p:pnode;

begin

p:=dian[a];

while p<>nil do

begin

if p^.d=b then

begin

if p^.q>c then

p^.q:=c;

exit(true);

end;

p:=p^.next;

end;

exit(false);

end;

procedure readdata;

var

i,a,b,c:longint;

begin

read(n,m,t);

for i:=1 to m do

begin

read(a,b,c);

if not flag(a,b,c) then insert(a,b,c);

if not flag(b,a,c) then insert(b,a,c);

end;

end;

procedure main;

var

k,i,l,r:longint;

p:pnode;

sum:int64;

begin

fillchar(dist,sizeof(dist),$7);

fillchar(v,sizeof(v),0);

dist[1]:=0;

v[1]:=true;

l:=1; r:=1;

f[1]:=1;

while l<=r do

begin

k:=f[l];

inc(l);

p:=dian[k];

while p<>nil do

begin

if dist[p^.d]>dist[k]+p^.q then

begin

dist[p^.d]:=dist[k]+p^.q;

if not v[p^.d] then

begin

inc(r);

f[r]:=p^.d;

v[p^.d]:=true;

end;

end;

p:=p^.next;

end;

v[k]:=false;

end;

sum:=0;

for i:=2 to n do

sum:=sum+dist[i]*2;

//sum:=sum*2;

writeln(sum);

if sum>t then

writeln('escape')

else

writeln('run');

end;

begin

init;

readdata;

main;

terminate;

end.

#1 xxyyttxx@2013-10-28 04:46:00
回复 删除
= =

数据错了

你答案对的

cheat吧

查看更多回复
提交回复