From 84f7542dae465a99ed9595690bca02738f5e5974 Mon Sep 17 00:00:00 2001 From: Kirito <1362050620@qq.com> Date: Mon, 22 Aug 2016 14:09:19 +0800 Subject: [PATCH] Update SPFA.cpp Edited. val m is needn't. --- .ACM-Templates/SPFA.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.ACM-Templates/SPFA.cpp b/.ACM-Templates/SPFA.cpp index 6423a5a..2ae8453 100644 --- a/.ACM-Templates/SPFA.cpp +++ b/.ACM-Templates/SPFA.cpp @@ -1,17 +1,20 @@ +/** SPFA 单源最短路径算法 不支持负环*/ namespace SPFA { -const int MAXN = 110; -int d[MAXN];/// distance +const int MAXN = 1005; +int d[MAXN];/// distance [ From S to ... ] int v[MAXN];/// visit int q[MAXN];/// 基于数组的队列(也可用queue等...) -int n;///点总数 -int m;///边总数 -int mp[MAXN][MAXN]; /// mp[i][j] 表示i<--> j 连通 从1开始 +int mp[MAXN][MAXN]; /// mp[i][j] ???<--> j ?? ?1?? +int n; int spfa(int s,int t) { - for(int i=1;i<=n;i++) - d[i]=INF,v[i]=0; + memset(d,0x3f,sizeof(d)); + memset(v,0,sizeof(v)); + /* + for(int i=1;i