floyd: 62MS
View Code
dijkstra: 15MS 1 #include2 using namespace std ; 3 #define maxn 210 4 const int oo = 1<<28 ; 5 int map[maxn][maxn] ; 6 int n ; 7 void init() 8 { 9 for(int i=0; i map[i][k]+ map[k][j])23 map[i][j] = map[i][k] + map[k][j] ;24 }25 int main()26 {27 int m, a, b, c, s, t ;28 while(cin>>n>>m)29 {30 init() ;31 while(m--)32 {33 cin>>a>>b>>c ;34 if(map[a][b]>c)35 map[a][b] = map[b][a] = c ;36 }37 cin>>s>>t ;38 floyd() ;39 if(map[s][t]
View Code
1 #include2 #include