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

Автор Master_Prog, 12 лет назад, По-русски

What is wrong in my code ?
450D - Jzzhu и города
7166454

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

»
12 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Here you go:

3 1 2
2 3 1
2 1
3 3

In this test case the shortest path to city 3 is through city 2 (i.e. the shortest path starts with rails, then ends with a road). So, the answer should be 1, but your code returns 0.

In your code it seems like you do not actually consider rails in your implementation of Dijkstra's algorithm.

Good luck!

P.S.: if you wonder why you got so many 'dislikes' then consider to be more polite to the community, especially when you ask for help ;)