Given $$$n$$$ points on a plane. Each point has coordinates $$$x_i$$$, $$$y_i$$$ and a color $$$c_i$$$, which can be white ($$$c_i=0$$$) or black ($$$c_i=1$$$).
To determine the color of a new point $$$P$$$, if it is unknown, the following approach can be used. The $$$k$$$ nearest points to it (where $$$k$$$ is some odd number) are taken, and the color that occurs most frequently among them is chosen. Note: the measure of proximity between two points can be calculated in different ways; in this problem, the usual Euclidean distance is used (i.e., the length of the segment between the points).
The quality of such a classifier depends on the choice of the parameter $$$k$$$. To find a good value for $$$k$$$, the following simple method can be used. We will look at what answers we get for our input points (for which the correct answers are known) with different $$$k$$$, and we will choose the value of $$$k$$$ for which the number of correct answers is maximized. This method is called "LOO cross-validation."
Let's explain how this method works in more detail. We will iterate through all odd values of $$$k$$$ in the range from $$$1$$$ to $$$n-1$$$. For each such $$$k$$$, we will iterate through all points. For each of them, we will find the $$$k$$$ nearest other points (not counting itself), take the color that occurs most frequently among them, and compare it with the actual color of that point. The more correct answers we get for the current value of $$$k$$$, the better that value is. Of course, to improve efficiency, the described implementation of the algorithm can be modified — the main thing is that the results remain correct.
Write a program that determines for each odd $$$k$$$ in the range from 1 to $$$n$$$ how many points will have their color correctly classified for the given $$$k$$$ during LOO cross-validation.
The first line of the input contains an integer $$$n$$$ ($$$2 \le n \le 1000$$$).
The following $$$n$$$ lines contain triples of numbers $$$x_i$$$, $$$y_i$$$, and $$$c_i$$$ — the coordinates of the next point ($$$-20000 \le x_i, y_i \le 20000$$$) and its color $$$c_i$$$ (which is either 0 or 1).
It is guaranteed that no two points coincide and the distances between all pairs of points are distinct.
Output the number of correctly classified points for $$$k=1$$$, $$$k=3$$$, $$$k=5$$$, and so on up to $$$n-1$$$ (if $$$n-1$$$ is even, then up to $$$n-2$$$). You do not need to output the values of $$$k$$$ themselves.
41 2 0-3 1 10 0 14 5 0
2 0
Subtask 1 (up to 30 points): $$$n \le 50$$$.
Subtask 2 (up to 30 points): $$$n \le 200$$$.
Subtask 3 (up to 40 points): $$$n \le 1000$$$.
Note for those writing in Python. You can input three numbers separated by spaces like this:
x, y, c = [int(x) for x in input().split()]