Circle Artwork
Time limit1sMemory limit128 MB
Given up to 100 colored points, count how many colors have a circle through two of their points that contains no point of another color.
- Level
Hard8 of 10
- Topics
- Geometry, Brute force, Sorting, Implementation
- Solved
- No attempts yet
Problem
The circle is an ancient and universal symbol of unity, wholeness, and infinity. Playing the role of a modern artist, we want to compose a painting from colored points and circles.
First we place several colored points on the canvas. For each color we would like to draw one circle that satisfies both of the following conditions:
- every colored point lying inside the circle or on its boundary has color ;
- at least two colored points lie on the boundary of the circle.
Since a point on the boundary is a point "inside or on the boundary", any boundary point must itself have color . Hence a valid circle for color passes through at least two points of color and contains no point of any other color, neither strictly inside nor on the boundary. Points of color may lie inside, on, or outside the circle. For some colors no such circle exists.
Given the colored points, determine the largest number of colors for which such a circle exists — that is, how many colors admit at least one valid circle.
Input
The input contains several test cases. Each test case begins with a line containing a single integer (), the number of colored points. Each of the next lines has the form C X Y, where C is the color of the point (a string of at most lowercase English letters) and , are its integer coordinates with .
The input ends with a line containing a single .
Output
For each test case, print a single line containing the largest number of colors for which a valid circle exists.