Why priority queue can not used in the code?

In priority queue, we have same operations as we have in sets. Here we can create min heap.

@mb129162,
You can use either.
Set may give a better runtime as in that we can erase any element, thus we can remove any redundant ones as we get them, but in priority_queue we can only remove top.