Editorial for COCI '07 Contest 3 #4 Dejavu
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.
Suppose we choose the point in which the angle is degrees. Because the legs of the triangle must be parallel to the coordinate axes, then one of the other two points must have the same x-coordinate as , and the other must have the same y-coordinate. The exact number of triangles is .
Because the limit is low enough, we can pre-calculate and for each and in two arrays. The time complexity of the algorithm is , where is the limit on the coordinates.
Comments