When read the top voted solution on the forum I was literally over shocked. My first feeling was that it could not be good, and with a trivial variation of that solution it has been quickly failed.
Note that it has also a serious precision issue (due to a math logic error)
using the topvoted solution https://leetcode.com/problems/best-position-for-a-service-centre/discuss/731577/C%2B%2B-with-picture-zoom-in
Yours=16.22013; better=16.21810 (with px=6.928571544,py=5.500000254);
points={{8,7},{5,1},{3,0},{8,8}}
Then checked the fastest contestant's solutions, it is very sad, but many top solutions, and ofcourse not only those are (totally) broken. I've run 10k random tests on the first ten solutions. (not counting the 9th because that is c#).
Printed my px,py values up to 9 decimals (it could be non-optimal in many cases)
(note that the scores are rounded to 5 digits), and chosen not so close counter-examples
to clearly show the errors in their codes:
2nd contestant LayCurse
Yours=16.14214; better=16.12645 (with px=0.250000000,py=2.250000000);
points={{1,9},{0,0},{0,2},{5,7}}
3rd contestant cuiaoxiang
Yours=10.89949; better=10.89928 (with px=5.004375890,py=2.015671715);
points={{4,9},{5,2},{6,1},{4,2},{6,3}}
4th contestant hitonanode
Yours=10.45254; better=10.44766 (with px=5.000000000,py=6.000000000);
points={{4,2},{6,9},{5,6},{4,3}}
10th contestant RadianceSheep
Yours=5.00000; better=4.83656 (with px=5.467170882,py=7.521374668);
points={{6,5},{6,8},{4,8}}