Whats wrong with this code?
Not getting AC while th ecode is getting AC at leetcode
Since p * p+q * q can form a very large value. Use long long int in place of int and then check.
Also if you are using a min heap, then you have to use an extra parameter for it
priority_queue< int, vector< int >, greater < int > >
after doing long long ,also it didn’t work…And,I am using max heap
Also note that you have to print the answer in sorted order.
Share your updated code’s link.
Sorted order means Distance wise sorted order?
Because in sample output its -2 4 & 3 3 which is not following sorted order
Your output is not in sorted order.
Check for this case:
12
-784 3784
-1820 2072
-5276 3050
-3376 3806
-3013 1039
-4846 4421
-1414 2038
-5342 473
-2606 4207
-685 114
-134 4994
-5890 2424
6
Your o/p:
-2606 4207
-784 3784
-3013 1039
-1820 2072
-1414 2038
-685 114
Ordering must be like this
-3013 1039
-2606 4207
-1820 2072
-1414 2038
-784 3784
-685 114
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.