/* The proper way to do this is with Union Find, but binary search works OK, too. O(n^2 log d) where d is the max distance. The recursive connected components implementaiton is a dog on Sun SPARC. */ #include #include #include #include int i,j,k,N,C,P; int x[1000],y[1000]; double dsq,delta; int mark[1000]; void set(int w, int c, double d) { int i,j,k; if (mark[w]) return; mark[w] = c; for (i=0;i .00001; delta *=.5) { if (try(dsq) > C) dsq += delta; else dsq -= delta; } printf("%0.2lf\n",sqrt(dsq)); } }