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
You could have a negative cycle, which isn't on the main path.
so does it mean that we can't have any negative cycle on any vertex except at N.
You can't have a cycle on any path between 1 and N, as that will become the shortest path.