import java.util.ArrayList; import java.util.Scanner; /** * 贝尔曼-福特算法 * * Bellman - ford算法是求含负权图的单源最短路径算法,效率较低. * @author CEMABENTENG * */public class BellmanFord{ private static int n, m; private static final int MAXN = 100; private static final int…
include const int inf=0x3f3f3f3f; int main() { int m,n; scanf("%d%d",&n,&m); int u[n+1],v[n+1],w[n+1]; for(int i=1; i<=m; i++) scanf("%d%d%d",&u[i],&v[i],&w[i]); int dis[n+1]; for(int i=1; i<=n; i++) dis[i]=in…