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

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

Автор i_love_sharapova, история, 4 года назад, По-английски

i was solving problem D-SCORE ATTACK of ABC 061 and i tried implementing classic bellman ford algorithm by changing the weight to -ve weight ,so as if any negative cycle occurs then that means score will be continuously increasing but i am getting WA ,i don't know where i am making mistake and i have assumed that graph is connected so either my assumption is wrong or i am implementing wrong algorithm .please can you guys help ? sorry if my english is bad.

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

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

You could have a negative cycle, which isn't on the main path.

N = 5
1 5 2
1 2 5
2 3 -1
3 2 -1