对于最短路的两种算法的分析对比报告
首先我们看两份代码:
这是 dij 的一份代码,其中删去了通常 dij 算法使用的 vis 标记数组。
题目链接
#include <bits/stdc++.h>
using namespace std;
#define _for(i, a, b) for(int i = (a); i <= (b); i ++)
inline void read(int &x, int &y, int &z) {
scanf("%d%d%d", &x, &y, &z); }
const int N = 2509, M = 6209;
int n, m;
int head[N], to[2 * M], nex[2 * M], wi[2 * M], tot;
void add(int x, int y, int w) {
nex[++ tot] = head[x]; head[x] = tot; to[tot] = y; wi[tot] = w;
}
int f[N];
struct node {
int w, x;
bool operator < (const node & no) const {
return w > no.w;
}
node (int</