记录编号 |
32566 |
评测结果 |
AAAAAAAAAA |
题目名称 |
燃烧 |
最终得分 |
100 |
用户昵称 |
Des. |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.013 s |
提交时间 |
2011-11-07 12:29:59 |
内存使用 |
1.47 MiB |
显示代码纯文本
program firez;
uses math;
var x1,x2,y1,y2,c:array[1..40]of longint;
t,k,m,n,i,j,z:longint;
a,d:array[1..200,1..200]of real;
b:array[1..200]of boolean;
x,y:array[1..200]of longint;
bo:array[-200..200,-200..200]of longint;
p:array[1..200]of boolean;
f:array[1..200]of real;
s:real;
begin
assign(input,'firez.in');
reset(input);
assign(output,'firez.out');
rewrite(output);
readln(n);
fillchar(bo,sizeof(bo),0);
fillchar(p,sizeof(p),false);
for t:=1 to n do
begin
readln(x1[t],y1[t],x2[t],y2[t],c[t]);
if (bo[x1[t],y1[t]]=0)and(bo[x2[t],y2[t]]=0) then
begin
a[z+1,z+2]:=c[t];
a[z+2,z+1]:=c[t];
x[z+1]:=x1[t];
y[z+1]:=y1[t];
x[z+2]:=x2[t];
y[z+2]:=y2[t];
bo[x1[t],y1[t]]:=z+1;
bo[x2[t],y2[t]]:=z+2;
z:=z+2;
end
else if bo[x1[t],y1[t]]=0 then
begin
k:=bo[x2[t],y2[t]];
a[z+1,k]:=c[t];
a[k,z+1]:=c[t];
x[z+1]:=x1[t];
x[z+2]:=y1[t];
bo[x1[t],y1[t]]:=z+1;
inc(z);
end
else if bo[x2[t],y2[t]]=0 then
begin
k:=bo[x1[t],y1[t]];
a[z+1,k]:=c[t];
a[k,z+1]:=c[t];
x[z+1]:=x2[t];
y[z+1]:=y2[t];
bo[x2[t],y2[t]]:=z+1;
inc(z);
end
else
begin
i:=bo[x1[t],y1[t]];
j:=bo[x2[t],y2[t]];
a[i,j]:=c[t];
a[j,i]:=c[t];
end;
p[bo[x1[t],y1[t]]]:=true;
p[bo[x2[t],y2[t]]]:=true;
end;
fillchar(b,sizeof(b),false);
for t:=1 to n do
for k:=t+1 to n do
if (max(x1[t],x2[t])=max(x1[k],x2[k]))
and(max(y1[t],y2[t])=max(y1[k],y2[k]))
and(abs(x2[t]-x1[t])+abs(y2[t]-y1[t])=2)
and(abs(x2[k]-x1[k])+abs(y2[k]-y1[k])=2) then
begin
inc(z);
i:=bo[x1[t],y1[t]];
j:=bo[x2[t],y2[t]];
a[z,i]:=a[i,j]/2;
a[i,z]:=a[z,i];
a[z,j]:=a[i,z];
a[j,z]:=a[i,z];
i:=bo[x1[k],y1[k]];
j:=bo[x2[k],y2[k]];
a[z,i]:=a[i,j]/2;
a[i,z]:=a[z,i];
a[j,z]:=a[z,i];
a[z,j]:=a[z,i];
end;
for i:=1 to z do
for j:=1 to z do
d[i,j]:=a[i,j];
for k:=1 to z do
for i:=1 to z do
for j:=1 to z do
if (i<>k)and(j<>k)and(i<>j)and(a[i,k]>0)and(a[k,j]>0)
and((a[i,k]+a[k,j]<a[i,j])or(a[i,j]=0)) then
a[i,j]:=a[i,k]+a[k,j];
for i:=1 to z do
if p[i] then
for j:=1 to n do
begin
t:=bo[x1[j],y1[j]];
k:=bo[x2[j],y2[j]];
if abs(a[i,t]-a[i,k])=d[t,k] then s:=max(a[i,t],a[i,k])
else s:=max(a[i,t],a[i,k])+((d[t,k]-abs(a[i,t]-a[i,k]))/2);
if s>f[i] then f[i]:=s;
end;
s:=maxlongint;
for i:=1 to z do
if (p[i])and(f[i]<s) then
s:=f[i];
writeln(s:0:4);
close(output);
end.