BFS (Shortest Path)

Sir , i used simple bfs , but got TLE . Any hint or optimisation?

Code = https://ideone.com/iFXzA8

hello @shivampandey9599
a)
u dont need to use anything extra simple bfs should work.

b) image
probably this could a reason for tle.

try to create fresh vector and array ,istead of clearing previous one,this might save some time