【Warshall_Floyd】

模板:

 /*
Problem: 任意两点间的最短路
Tips : 可以处理边时负数的情况。
判断图中是否有负圈,只需检查d[i][j]是负数的顶点i就可以。
复杂度 : O(n^3)
*/ #include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;
const int MAX_V = ;
int d[MAX_V][MAX_V]; //d[i][j]表示边e(i,j)的权值,不存在时为inf,d[i][i]=0;
int V, E; void Warshall_Floyd()
{
for(int k = ; k < V; k++)
for(int i = ; i < V; i++)
for(int j = ; j < V; j++)
d[i][j] = min(d[i][j], d[i][k] + d[k][j]); } int main()
{ return ;
}

Warshall_Floyd

上一篇:NOIP2010pj三国游戏[博弈论]


下一篇:js03-javascript对象