Editorial for DMPG '19 B5 - Triangles
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 a triangle whose vertices have -coordinates where . Note that if a point is contained in the interior of this triangle, then its -coordinate must be between and . Say we sort the points by their -coordinate. By the observation, if we form a triangle by three consecutive points after sorting, then it is guaranteed that no other point will be inside this triangle. The problem then reduces to finding three consecutive points which have at least one red and one blue point. Such a triplet exists if and only if there is at least one point of each colour. The triplet can easily be found since there are only to check.
Time Complexity:
Comments
nvm if there is at least 1 point of each color you can find a solution
That was what I considered but this works as well but very tricky to spot lawl
I took any blue and red point (if they exist) and then found the other point such that the area of the triangle formed is minimal. This way the complexity is just . If there would be another point inside the triangle formed of minimal size, we could have created a triangle of smaller area by using this point as the third point. But if this was the case, the triangle obtained of minimal area size is not minimal (contradiction). So there cannot be another point inside the triangle of minimal area.