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

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

I am attempting this question, and I am getting a couple of wrong answer for big test cases but every thing seems to work fine for small test cases.

Here's my approach...

-Firstly find shortest path from 1 to every node. (answers in array d1)

-Then find shortest path from N to every node (on Inverted graph) which means finding shortest path from every node to N.(answers in array d2)

-Then consider each edge in graph , suppose you are applying discount on that edge... then if we can reach 1 to a and N to b (in short b to N) then ans = min( ans , d1[a] + d2[b] + edge.weight/2 )

Here is my code

Can someone please help me with it? What am I doing wrong?

Полный текст и комментарии »

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

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

Can anyone please tell me where I am going wrong with this? Whenever my last move is not air, I move to air and when the last move is air, I find the maximum time on performing water or fire move. I am a beginner at dp, so any suggestion would help. Thanks. Question | My submission

Полный текст и комментарии »

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