In today's ABC305, I used multisource BFS to solve problem E. But it is giving TLE. Can anyone please point out the mistake? Moreover, an almost similar question also happened to appear in Codechef STARTERS 93. And an almost similar code, written by me, got accepted in it.
Problem Link: https://atcoder.jp/contests/abc305/tasks/abc305_e
Solution Link: https://atcoder.jp/contests/abc305/submissions/42175490
Code