//---------------------------------------------------------------------- // File: prob.cpp // Programmer: David Mount // Last modified: Mar 2003 // Description: Pippin's garden problem (max empty square) //---------------------------------------------------------------------- // This program solves Pippin's garden problem in which we are // given as input an axis-aligned rectangle (Pippin's yard) and a // set of points in this rectangle (trees) and we are asked to // compute the largest square (the garden) contained within this // rectangle, such that none of the points are in the interior of // this square. All inputs are in integer coordinates. //---------------------------------------------------------------------- #include // standard library #include // input/ouput #include // assertion checking // Uncomment the following lines if using APCS classes // #include "apvector.h" // #include "apmatrix.h" // #include "apstack.h" // #include "apqueue.h" // #include "apstring.cpp" //---------------------------------------------------------------------- // Point2D - a 2-dimensional point with integer coordinates //---------------------------------------------------------------------- typedef int Coord; // coordinates are ints enum Axis {X = 0, Y = 1}; // axis names class Point2D { private: Coord c[2]; // coordinates public: Point2D(Coord x = 0, Coord y = 0) // constructor { c[X] = x; c[Y] = y; } Coord& operator[](Axis i) // index { return c[i]; } }; // input operator istream& operator>>(istream& in, Point2D& p) { return in >> p[X] >> p[Y]; } // output operator ostream& operator<<(ostream& out, Point2D& p) { return out << p[X] << " " << p[Y]; } ///////////////////// BEGIN your code ///////////////////// // whatever additional classes & helper functions ///////////////////// END your code ///////////////////// //---------------------------------------------------------------------- // Main program // Inputs outer rectangle and points and calls findGarden() to // compute the garden. //---------------------------------------------------------------------- int main() { const int MAX_PTS = 10000; // maximum number of points int nPts; Point2D pts[MAX_PTS]; // array of points Coord outerWidth, outerHeight; // outer rectangle size cin >> outerWidth >> outerHeight; cin >> nPts; // input number of points assert(nPts <= MAX_PTS); for (int i = 0; i < nPts; i++) { // input the points cin >> pts[i]; } ///////////////////// BEGIN your code ///////////////////// // code to actually find biggest square ///////////////////// END your code ///////////////////// return EXIT_SUCCESS; }