Editorial for Facebook Hacker Cup '17 Qualifying Round P1 - Progress Pie

Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

For each point, we need to check two things:

1) Is the point close enough to the center that it could be within the circle at all?

This is as simple as computing the distance between the point and the center of the circle: \sqrt{(X-50)^2 + (Y-50)^2}. This distance must be no greater than 50, the radius of the circle.

2) Is the point between the two lines that define the bounds of the current circle sector?

We'd like to know the angle of the given point in the reference frame where 0 degrees is up and 90 degrees is to the right, since that's the way the boundary of the circle sector moves as the progress increases.

Most languages have an atan2() function which can give you the angle from (0, 0) to a given point. However, this function puts 0 degrees to the right and 90 degrees upwards, so it's necessary to translate the output to the desired reference frame.

And of course, if P = 0\%, all points are white.


There are no comments at the moment.