Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя darkprinx

Автор darkprinx, история, 9 лет назад, По-английски

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

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
9 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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.