#include #include float cx[1001], cy[1001]; int n; float dist (float x1, float y1, float x2, float y2) { return (x1-x2) * (x1-x2) + (y1-y2) * (y1-y2); } float signedarea (float x1, float y1, float x2, float y2, float x3, float y3) { return ((x2-x1)*(y3-y1) - (y2-y1)*(x3-x1))/2; } char intersects (float xa1, float ya1, float xa2, float ya2, float xb1, float yb1, float xb2, float yb2) { return (( signedarea(xa1, ya1, xa2, ya2, xb1, yb1) *signedarea(xa1, ya1, xa2, ya2, xb2, yb2) <= 0) && ( signedarea(xb1, yb1, xb2, yb2, xa1, ya1) *signedarea(xb1, yb1, xb2, yb2, xa2, ya2) <= 0)); } char clear (float x1, float y1, float x2, float y2) { int i; for (i = 0; i < n; i ++) if (intersects (x1, y1, x2, y2, cx[i], cy[i], cx[(i+1)%n], cy[(i+1)%n])) return 0; return 1; } int main (void) { int k, K; int r, p, i, j; float rx[1001], ry[1001]; float x, y; float bd; FILE *in = fopen ("ee.in", "r"); fscanf (in, "%d\n", &K); for (k = 1; k <= K; k ++) { printf ("Data Set %d:\n", k); fscanf (in, "%d %d %d\n", &n, &r, &p); for (i = 0; i < n; i ++) fscanf (in, "%f %f\n", &cx[i], &cy[i]); for (i = 0; i < r; i ++) fscanf (in, "%f %f\n", &rx[i], &ry[i]); for (i = 0; i < p; i ++) { fscanf (in, "%f %f\n", &x, &y); bd = -1; for (j = 0; j < r; j ++) if (clear (x, y, rx[j], ry[j]) && (bd < 0 || dist(x, y, rx[j], ry[j]) < bd)) bd = dist(x, y, rx[j], ry[j]); if (bd > 0) printf ("%.2f\n", 1/bd); else printf ("0.00\n"); } } fclose (in); return 0; }