Hi! I was trying to implementing the generic version of BFS, and the resultant code is giving TLE, even though for the sample examples it’s working fine. The code is present here at https://ide.codingblocks.com/s/179189. It would be great if anybody helps.
BFS-ShortestPathChallenge
Try adding fast input ouput for c++.
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
Also dont make pointer templates for simple problems. It is because when you are deleting the length at last it might take a lot of time for all the queries. Instead use standard template libraries for simpler implementation.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.