#include using namespace std; const int MAX = 50; const int MAXP = 2500; class loc { public: int r, c; }; loc offense[MAXP]; class box { public: int x1, y1, x2, y2; void swap(double& a, double& b, double& c, double& d) { double tmp = a; a = c; c = tmp; tmp = b; b = d; d = tmp; } bool between(double a, double b, double c) { return (a >= b && a <= c); } bool intersectInterval(double a, double b, double c, double d) { return between(a,c,d) || between(b, c, d) || between(c, a, b) || between(d, a, b); } bool intersect(double a, double b, double c, double d) { // special case: pass within defender's box if (between(a, x1, x2) && between(c, x1, x2) && between(b, y1, y2) && between(d, y1, y2)) return true; // special cases: vertical pass... if (a == c) { if (!between(a, x1, x2)) return false; return intersectInterval(min(b,d), max(b,d), y1, y2); } // ... and horizontal pass else if (b == d) { if (!between(b, y1, y2)) return false; return intersectInterval(min(a,c), max(a,c), x1, x2); } // check for intersection on left and right if (c < a) swap(a, b, c, d); if (x2 < a || x1 > c) return false; if (between(x2, a, c)) { //cout << "x2 = " << x2 << endl; //cout << " a, b, c, d = " << a << ',' << b << ',' << c << ',' << d << endl; double y = b + (x2-a)*(d-b)/(c-a); //cout << " y = " << y << endl; //cout << " y1, y2 = " << y1 << ',' << y2 << endl; if (between(y, y1, y2)) return true; } if (between(x1, a, c)) { //cout << "x1 = " << x1 << endl; //cout << " a, b, c, d = " << a << ',' << b << ',' << c << ',' << d << endl; double y = b + (x1-a)*(d-b)/(c-a); //cout << " y = " << y << endl; //cout << " y1, y2 = " << y1 << ',' << y2 << endl; if (between(y, y1, y2)) return true; } // check for intersection on top and bottom if (d < b) swap(a, b, c, d); if (y2 < b || y1 > d) return false; if (between(y2, b, d)) { double x = a + (y2-b)*(c-a)/(d-b); if (between(x, x1, x2)) return true; } if (between(y1, b, d)) { double x = a + (y1-b)*(c-a)/(d-b); if (between(x, x1, x2)) return true; } return false; } }; box defense[MAXP]; int main() { int r, c, no, nd, icase = 0; cin >> r >> c >> no >> nd; while (r > 0) { icase++; for(int i=0; i> offense[i].r >> offense[i].c; } for(int i=0; i> r >> c; defense[i].x1 = c-1; defense[i].y1 = r-1; defense[i].x2 = c+2; defense[i].y2 = r+2; } cout << "Case " << icase << ":"; double a = offense[0].c + 0.5; double b = offense[0].r + 0.5; for(int i=1; i> r >> c >> no >> nd; } }