improve some template codes.
add solution for floyd warshall's algorithm