I’ve actually been thinking about this assigned problem for a while, but I can’t get anywhere… I know Bellman-Ford, Dijkstra and Floyd Warshall.
Pretty much it’s a standard shortest path problem with V verticies and E edges, each edge with a length L and a color C. They are bidirectional.
The only constraint is that you should find the length of the shortest path without going on 2 consecutive edges with the same color.
Floyd-warshall could work if V was smaller, but V is bounded by (3, 50000).
Any help? thoughts?
Try something like Dijkstra’s, but keep track of the shortest path ending in a particular color to each vertex.