mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Update SPFA.cpp
Edited. val m is needn't.
This commit is contained in:
parent
9699aa218a
commit
84f7542dae
|
@ -1,17 +1,20 @@
|
||||||
|
/** SPFA 单源最短路径算法 不支持负环*/
|
||||||
namespace SPFA
|
namespace SPFA
|
||||||
{
|
{
|
||||||
const int MAXN = 110;
|
const int MAXN = 1005;
|
||||||
int d[MAXN];/// distance
|
int d[MAXN];/// distance [ From S to ... ]
|
||||||
int v[MAXN];/// visit
|
int v[MAXN];/// visit
|
||||||
int q[MAXN];/// 基于数组的队列(也可用queue等...)
|
int q[MAXN];/// 基于数组的队列(也可用queue等...)
|
||||||
int n;///点总数
|
int mp[MAXN][MAXN]; /// mp[i][j] ???<--> j ?? ?1??
|
||||||
int m;///边总数
|
int n;
|
||||||
int mp[MAXN][MAXN]; /// mp[i][j] 表示i<--> j 连通 从1开始
|
|
||||||
|
|
||||||
int spfa(int s,int t)
|
int spfa(int s,int t)
|
||||||
{
|
{
|
||||||
for(int i=1;i<=n;i++)
|
memset(d,0x3f,sizeof(d));
|
||||||
d[i]=INF,v[i]=0;
|
memset(v,0,sizeof(v));
|
||||||
|
/*
|
||||||
|
for(int i=1;i<MAXN;i++)
|
||||||
|
d[i]=INF,v[i]=0;*/
|
||||||
int cnt=0;
|
int cnt=0;
|
||||||
q[cnt++]=1;
|
q[cnt++]=1;
|
||||||
v[1]=1;
|
v[1]=1;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user