Problems > Three in a Line > Editorial

Three in a Line — Solution & Editorial

Back to the Problem

Cross product of the two difference vectors is zero exactly on collinearity — integer-exact, no slopes, no division.

Complexity: O(1)

Watch out: Slope comparison divides by zero on vertical lines and rounds off at 109; the cross product does neither.