Unable to find why i am getting WA on problem ELWINTER recent march lunchtime problem

I have used muti source bfs and mark all the nodes minimum time required by them to get frozen and print the answer based on whether it is frozen
(I am printing the answer right away i just store at what time query of checking is being asked and
after all kind of information gathered performed bfs then checked the nodes but i am getting lots of wa
i don’t think there is any mistake in implementation neither in thinking of this solution please help me out
)
CodeChef: Practical coding for everyone (problem link)
CodeChef: Practical coding for everyone(submission link)

Check the following submission.

Accepted

don’t get me wrong i understand the accepted code but i want to know what i am doing wrong

Hey @kokoite908 :wave: ,
Your Logic is not correct because after taking all queries and those that have not been froze yet you have taken and did multisource bfs but in your bfs you actually freezing those node that should not be this is because you have taken their initial time as infinity so your bfs keep on finding new neighbours. try to solve while taking queries and solving samultaneously(online).
If you are not able to solve don’t worry you can check out editorial for this problem.