/* [NWERC'07] FLIGHT SAFETY by: Jan Kuipers */ using namespace std; #include #include #include #include const double eps = 1e-9; typedef pair PDD; struct point { double x,y; point(): x(0), y(0) {} point(double _x, double _y): x(_x), y(_y) {} }; int N,C; vector r; vector > p; point operator * (double x, point a) { return point(x*a.x, x*a.y); } point operator + (point a, point b) { return point(a.x+b.x, a.y+b.y); } point operator - (point a, point b) { return point(a.x-b.x, a.y-b.y); } double operator * (point a, point b) { return a.x*b.x + a.y*b.y; } double operator ^ (point a, point b) { return a.x*b.y - a.y*b.x; } point norm (point a) { return 1/sqrt(a*a) * point(a.y,-a.x); } void read () { cin>>C>>N; r=vector(N); p=vector >(C); for (int i=0; i>r[i].x>>r[i].y; for (int i=0; i>n; p[i]=vector(n); for (int j=0; j>p[i][j].x>>p[i][j].y; p[i].push_back(p[i][0]); double area=0; for (int j=0; j intervalspolygon (point a, point b, vector p) { vector ts; ts.push_back(0); ts.push_back(1); for (int i=0; i1+eps) continue; if (s<-eps || s>1+eps) continue; ts.push_back(t); } sort(ts.begin(),ts.end()); vector res; for (int i=0; i intervalscircle (point a, point b, point p, double r) { double A = (b-a)*(b-a); double B = 2*(b-a)*(a-p); double C = (a-p)*(a-p) - r*r; vector res; if (B*B-4*A*C < 0) return res; double t1 = (-B-sqrt(B*B-4*A*C)) /2/A; double t2 = (-B+sqrt(B*B-4*A*C)) /2/A; if (t2<-eps || t1>1+eps) return res; res.push_back(make_pair(max(t1,0.0),min(t2,1.0))); return res; } void solve () { double lo=0, hi=40000; for (int times=0; times<50; times++) { double dist = (lo+hi)/2; int ok=1; for (int i=0; i ivals; for (int j=0; j tmp = intervalspolygon(r[i], r[i+1], p[j]); ivals.insert(ivals.end(), tmp.begin(), tmp.end()); } for (int j=0; j sq; sq.push_back(a + dist * n); sq.push_back(a - dist * n); sq.push_back(b - dist * n); sq.push_back(b + dist * n); sq.push_back(a + dist * n); vector tmp = intervalspolygon(r[i], r[i+1], sq); ivals.insert(ivals.end(), tmp.begin(), tmp.end()); tmp = intervalscircle(r[i], r[i+1], p[j][k], dist); ivals.insert(ivals.end(), tmp.begin(), tmp.end()); } sort(ivals.begin(),ivals.end()); double to=0; for (int j=0; j to+eps) ok=0; to >?= ivals[j].second; } if (to < 1-eps) ok=0; if (!ok) break; } if (ok) hi=dist; else lo=dist; } cout<>runs; while (runs--) { read(); solve(); } return 0; }