C++ dynamic programming to solve TSP problem (memorand method)