## Editorial for An Animal Contest 4 P3 - Snowy Slopes

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.

Author: sjay05

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.

Time Complexity:

• commented on Dec. 29, 2021, 7:12 p.m.

How would you count the amount of same values inside the id array?

• commented on Dec. 29, 2021, 10:54 p.m. edit 2

When solving for a particular slope , we can maintain the id's in a map <id value, frequency (# of points with that id value)>. For a id value with frequency you can form distinct pairs of points with slope .

For further help, ask in the DMOJ Discord.

• commented on Dec. 30, 2021, 12:06 a.m.

ah, ok, thanks a lot, for some reason I was thinking f frequency would form f! pairs, thanks a lot