SPFA 求最长路中
dis[to] 和 dis[t] + w 比较一定要编一个 double 的比较函数。
不能直接写 dis[to] < dis[t] + w,要写 cmp(dis[to], dis[t] + w) == -1。
dis[to] < dis[t] + w
cmp(dis[to], dis[t] + w) == -1
60分 -> 100分
我写的 cmp:
int cmp(double a, double b) { if (fabs(a - b) < eps) return 0; if (a < b) return -1; return 1; }