T1342 shortest path problem
发布时间
阅读量:
阅读量

思路
此题与模板题类似,区别仅在于图的权重需要自行计算。具体实现代码如下:
对于不熟悉Floyd算法的读者,可参考以下这篇文章
#include<iostream>
#include<iomanip>
#include<algorithm>
#define N 10001
#define INF 0x3f3f3f3f
using namespace std;
int x[N], y[N]; //用来存储每个点的x,y坐标
double g[N][N]; //用来记录点之间的距离
double calculate(int x1, int y1, int x2, int y2)
{//计算两点之间距离
return sqrt((double)(x1 - x2)*(x1 - x2) + (double)(y1 - y2)*(
全部评论 (0)
还没有任何评论哟~
