Getting tLE in second test case

@varun.saxena,
For every query of type 2, you are making a new priority_queue of size n, thus complexity if you code is O(q*n). Try to handle both query in almost O(log).

Hey,
I replaced with a set and maintain the size only to the required distance value. Now the TLE is gone, but I get an error now.

@varun.saxena,
Wrong link I guess.

@varun.saxena,
You don’t need to use set, you can simply use priority_queue in similar manner.

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.