2624: Big Campus
Result | TIME Limit | MEMORY Limit | Run Times | AC Times | JUDGE |
---|---|---|---|---|---|
3s | 8192K | 99 | 18 | Standard |
JLU is a big university consists of six campus. Since it is so big, there are school buses running in it. School bus only stops at bus station. There are n bus stations in JLU, p1...pn. The bus has m route. Each starts and ends at bus station and spends some time. Xiaoming is standing at ps and wants to go to pe. So there comes the question, how fast can Xiaoming go to pe. Xiaoming's walking speed is v. Xiaoming can choose to go by bus or walk. He can even choose to take both. You can assume the bus goes once he get on.
n, m // n <= 100, m <= n * n next n lines (xi, yi) coordinate of the bus station, float number next m lines i, j, t from the ith to jth spend t time v xs, ys // start point xe, ye // end point
a float number, the minimal time, 3digit after dot
2 2 0 0 100 100 1 2 1 2 1 1 1 0 0 99 100 4 3 1 1 50 50 51 51 100 100 1 2 1 2 3 100 3 4 1 5 0 0 99 99
2.000 2.849
Problem Source: provided by zzc
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
class campus
{
public:
double x,y;
};
double distance(double x1,double y1,double x2,double y2)
{
return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
int main()
{
campus a[105];
int n,m;
while(scanf("%d%d",&n,&m)==2)
{
double dis[105][105];
for(int i=0;i<105;i++) for(int j=0;j<105;j++) dis[i][j]=(1<<31)-1;
for(int i=1;i<=n;i++)
{
scanf("%lf%lf",&a[i].x,&a[i].y);
}
for(int i=1;i<=m;i++)
{
int xx,yy;
double t;
scanf("%d%d%lf",&xx,&yy,&t);
if(t<dis[xx][yy]) dis[xx][yy]=t;
}
double v;
scanf("%lf",&v);
scanf("%lf%lf%lf%lf",&a[n+1].x,&a[n+1].y,&a[n+2].x,&a[n+2].y);
for(int i=1;i<=n+2;i++)
for(int j=1;j<=n+2;j++)
dis[i][j]=min(dis[i][j],distance(a[i].x,a[i].y,a[j].x,a[j].y)/v);
/*for(int i=1;i<=n+2;i++)
{
for(int j=1;j<=n+2;j++)
cout<<dis[i][j]<<".....";
cout<<endl;
}*/
for(int k=1;k<=n+2;k++)
{
for(int i=1;i<=n+2;i++)
{
for(int j=1;j<=n+2;j++)
{
dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
}
}
}
printf("%.3lf/n",dis[n+1][n+2]);
}
return 0;
}
/*
4 3
1 1
50 50
51 51
100 100
1 2 1
2 3 100
3 4 1
5
0 0
99 99
*/