this submission using priority_queue is giving TLE : http://codeforces.net/contest/467/submission/43003735
where using set giving AC : http://codeforces.net/contest/467/submission/43003953
problem link: http://codeforces.net/contest/467/problem/D
could anyone point me out what is wrong here! i am literally not getting the point :(
I think you need to check whether not-unique items being inserting into container or not.
set keeps only unique items. priorityqueue doesn't. Therefore you can execute for-loop inside while-loop too many extra times and get TLE.
yes, thank you for pointing it out.
it is giving time limit for this 'non-unique' pushing.
if the edges are like:
1-x
2-x
...
...
...
n-x
then x will be pushed n times in the queue,which will lead the complexity to O(n^2).
it is sad that i have missed the point.
again thank you for pointing this.