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.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
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:
Comments
How would you count the amount of same values inside the id array?
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.
ah, ok, thanks a lot, for some reason I was thinking f frequency would form f! pairs, thanks a lot