标签:mem span false queue eof blog for max class
int dist[maxn],mp[maxn][maxn]; int visit[maxn]; void spfa() //SPFA算法 { int i, now; memset(visit, false, sizeof(visit)); for(i = 1; i <= n; i++) dist[i] = inf; dist[1] = 0; queue<int> Q; Q.push(1); visit[1] = true; while(!Q.empty()) { now = Q.front(); Q.pop(); visit[now] = false; for(i = 1; i <= n; i++) { if(dist[i] > dist[now] + mp[now][i]) { dist[i] = dist[now] + mp[now][i]; if(visit[i] == 0) { Q.push(i); visit[i] = true; } } } } }
标签:mem span false queue eof blog for max class
原文地址:http://www.cnblogs.com/lalalatianlalu/p/7823283.html