#include #include #include #include using std::pair; using std::map; const int maxpoints = 1000 + 1; int n; class point : public pair{ public: inline int & operator[](int ind){ return ind==0 ? first : second; }; inline int operator[](int ind) const { return ind==0 ? first : second; }; void print(){ printf("{%2d,%2d}", (*this)[0], (*this)[1]); }; }; point points[1000]; inline bool horizcomp(const point &a, const point &b){ if(a[0]!=b[0]) return a[0] < b[0]; return a[1] MV,MH; void init(){ t = new int*[2]; c = new int[maxpoints+1]; for(int a=0;a<2;++a){ t[a] = new int[maxpoints+1]; }; }; void initset(){ for(int i=0;ib->c; function returns c #ifdef DEB printf("\tnextpoint("); b.print(); printf(",%s) = ", horizontal ? "H" : "V" ); point x = (horizontal) ? MH[b] : MV[b]; x.print(); printf("\n"); #endif return (horizontal) ? MH[b] : MV[b]; }; }; walls_cl walls; void init(){ walls.init(); }; void initset(){ #ifdef DEB printf("---------NEXT SET----\n"); #endif walls.initset(); }; int main(){ point start, first, p, p0; init(); while (true) { bool o = false; scanf("%d", &n); if (n==0) return 0; //printf("%d - DEB\n", __LINE__); initset(); for (int i = 0; i