Firesec TLE

Dear friends,
I have been trying to solve the question
for a long time,my logic is definiely right wit complexity but why is it still showing TLE ,could u please help me with it,i already posted a question earlier but to no avail.
Could u please help me with it

I used BFS and my solution passed.
Link to my solution

Well if you are sure that your Algo is correct then Try Avoiding the use of push_back . push_back operation is very slow

This question is a basic Disjoint data structure question, Try using that concept.