| 1 | #define INC(c) ((c) == K - 1 ? 0 : (c) + 1) |
| 2 | template <int K> struct kd_tree { |
| 3 | struct pt { |
| 4 | double coord[K]; |
| 5 | pt() {} |
| 6 | pt(double c[K]) { rep(i,0,K) coord[i] = c[i]; } |
| 7 | double dist(const pt &other) const { |
| 8 | double sum = 0.0; |
| 9 | rep(i,0,K) sum += pow(coord[i] - other.coord[i], 2.0); |
| 10 | return sqrt(sum); } }; |
| 11 | struct cmp { |
| 12 | int c; |
| 13 | cmp(int _c) : c(_c) {} |