In this submission for the problem 31660028 the author used if(ans[ni][nj] < ans[v.fi][v.se] + 1) break;
condition. Can anyone guide me in proving that this algorithm with the break condition produces shortest paths and its complexity is O(n*m).
Problem Link: https://codeforces.me/problemset/problem/877/D
Auto comment: topic has been updated by Yuki726 (previous revision, new revision, compare).
Auto comment: topic has been updated by Yuki726 (previous revision, new revision, compare).
https://codeforces.me/blog/entry/55362?#comment-392068