I solve this problem by counting the number of intersections of the closed broken line and ray from (x0,y0+0.5) to left, but got WA on test case #15. Then I changed the ray from (x0, y0+0.5) to right, and got AC.
I performed a sanity check on the test data, and the test passed first 14 test cases but failed on #15: the closed broken line is without self-crossings and self-contacts, so every endpoints appears exactly twice in the broken line.
I hope the Codeforces maintainers verify the test data.