| 2 | struct naive_kd_tree { |
| 3 | |
| 4 | struct point { |
| 5 | double coord[K]; |
| 6 | point() {} |
| 7 | point(double c[K]) { |
| 8 | for (int i = 0; i < K; i++) |
| 9 | coord[i] = c[i]; |
| 10 | } |
| 11 | |
| 12 | double dist_to(const point &other) const { |
| 13 | double sum = 0.0; |
| 14 | for (int i = 0; i < K; i++) |
| 15 | sum += pow(coord[i] - other.coord[i], 2.0); |
| 16 | return sqrt(sum); |
| 17 | } |
| 18 | |
| 19 | bool operator <(const point &other) const { |
| 20 | for (int i = 0; i < K; i++) |
| 21 | if (abs(coord[i] - other.coord[i]) > EPS) |
| 22 | return coord[i] < other.coord[i]; |
| 23 | return false; |
| 24 | } |
| 25 | }; |
| 26 | |
| 27 | set<point> pts; |
| 28 | |