Please read the new rule regarding the restriction on the use of AI tools. ×

darkprinx's blog

By darkprinx, history, 9 years ago, In English

im having trouble to solve this problem. Lightoj 1271 . Any idea to solve this problem will hepl me a lot .. thnx in advance :)

  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

That's a classical shortest path problem. You can use Dijkstra's algorithm with edges of weight 1.

To find the lexicographically smallest you can sort the adjacency list of all the vertices before using Dijkstra's algorithm.

Feel free to message me if you still need help.