- Car的旅行路线
- 2016-06-12 21:11:33 @
这里 不能用STL吗?
4 条评论
-
1099493025 LV 7 @ 2017-04-18 21:15:19
好吧,是我智障啦。。。。。
-
2016-08-16 23:35:12@
我是P党,这是我在洛谷上发布的题解:
var dis:array[1..110,1..110] of double;//顾名思义,两点间的距离 x,y,tt:array[1..110] of longint;//用x y数组来记录各点的坐标,tt存储各城市公路的花费 n,xx,s,t,a,b,i,j,k:longint; ans:double; procedure ce(t1,t2:longint);//计算两个点之间的花费 begin dis[t1,t2]:=sqrt(sqr(x[t1]-x[t2])+sqr(y[t1]-y[t2])); if ((t1-1) div 4)=((t2-1) div 4) then dis[t1,t2]:=dis[t1,t2]*tt[((t1-1) div 4)+1] else dis[t1,t2]:=dis[t1,t2]*t; dis[t2,t1]:=dis[t1,t2]; end; function ver(t1,t2,t3:longint):longint;//找一个城市中已知三个点的顶点 begin if (dis[t1,t2]>dis[t2,t3]) and (dis[t1,t2]>dis[t3,t1]) then ver:=t3; if (dis[t2,t3]>dis[t1,t2]) and (dis[t2,t3]>dis[t3,t1]) then ver:=t1; if (dis[t3,t1]>dis[t2,t3]) and (dis[t3,t1]>dis[t1,t2]) then ver:=t2; end; procedure fpl(t1,t2,t3:longint);//计算第四个点的位置 t1,t2,t3为其他三个点的顺序 begin ce(t1,t2); ce(t2,t3); ce(t3,t1); if ver(t1,t2,t3)=t1 then begin x[t3+1]:=x[t3]+x[t2]-x[t1]; y[t3+1]:=y[t3]+y[t2]-y[t1]; end; if ver(t1,t2,t3)=t2 then begin x[t3+1]:=x[t3]+x[t1]-x[t2]; y[t3+1]:=y[t3]+y[t1]-y[t2]; end; if ver(t1,t2,t3)=t3 then begin x[t3+1]:=x[t1]+x[t2]-x[t3]; y[t3+1]:=y[t1]+y[t2]-y[t3]; end; end; begin readln(n); xx:=0; repeat inc(xx);//计算已处理了多少组数据 ans:=maxlongint; fillchar(dis,sizeof(dis),0);//初始化dis数组 readln(s,t,a,b); for i:=1 to s do begin readln(x[4*i-3],y[4*i-3],x[4*i-2],y[4*i-2],x[4*i-1],y[4*i-1],tt[i]); fpl(4*i-3,4*i-2,4*i-1); end; for i:=1 to 4*s do //绘制地图 for j:=1 to 4*s do ce(i,j); for k:=1 to 4*s do //floyd处理 for i:=1 to 4*s do for j:=1 to 4*s do if dis[i,k]+dis[k,j]<dis[i,j] then dis[i,j]:=dis[i,k]+dis[k,j]; for i:=4*a-3 to 4*a do //取最小值 for j:=4*b-3 to 4*b do if dis[i,j]<ans then ans:=dis[i,j]; writeln(ans:0:1); until xx=n; end.
-
2016-08-07 10:26:11@
数据不一样,程序鲁棒性不够,是不是这样?
-
2016-06-14 18:43:08@
我在Vijos上AC,结果到Luogu上WA40????
- 1