Editorial for An Animal Contest 4 P3 - Snowy Slopes
Submitting an official solution before solving the problem yourself is a bannable offence.
Consider all steepnesses (with taking into account duplicate steepnesses) separately. If some arbitrary point and point form a line with gradient :
By manipulating the equation:
Let of a point with coordinate be . In other words, for two points and to form a line with gradient , must be equal to .
Implementation details are left to the reader as an exercise.