/* Subject: Contest submission for problem #3, file 3.cc */ /* cyc@imail.EECS.Berkeley.EDU */ /* Thu Sep 11 01:00:15 PDT 2003 */ /*___CONTEST_SUBMISSION___ cyc 3 */ #include #include #include using namespace std; class window { public: int name, ch_length; int coordx, coordy, width, height; int open_x, open_y, open_w, open_h; vector children; window(int n, int x, int y, int w, int h); window *find(int num); }; window::window(int n, int cx, int cy, int w, int h) { name = n; coordx = cx; coordy = cy; width = w; height = h; open_x = cx; open_y = cy; open_w = w; open_h = h; ch_length = 0; } window *window::find(int num) { window *tmp = NULL; if(name == num) return this; else if(ch_length == 0) return NULL; else for(int i = 0;(i < ch_length) && (tmp == NULL); i++) tmp = children[i]->find(num); return tmp; } int main() { int mw, mh; int n, p, s; char d; int count = 1; window *tmp; vector temp; int c_x, c_y, c_w, c_h; cin >> mw >> mh; window outer(1, 0, 0, mw, mh); while(!cin.eof()) { cin >> n >> p >> s >> d; tmp = outer.find(p); tmp->ch_length = tmp->ch_length + 1; temp.resize(tmp->ch_length); for(int i = 0; i < tmp->ch_length - 1; i++) temp[i] = tmp->children[i]; switch(d) { case 'T': c_h = s; c_w = tmp->open_w; c_x = tmp->open_x; c_y = tmp->open_y + tmp->open_h - s; tmp->open_h = tmp->open_h - s; break; case 'B': c_h = s; c_w = tmp->open_w; c_x = tmp->open_x; c_y = tmp->open_y; tmp->open_y = tmp->open_y + s; tmp->open_h = tmp->open_h - s; break; case 'L': c_h = tmp->open_h; c_w = s; c_x = tmp->open_x; c_y = tmp->open_y; tmp->open_x = tmp->open_x + s; tmp->open_w = tmp->open_w - s; break; case 'R': c_h = tmp->open_h; c_w = s; c_x = tmp->open_x + tmp->open_w - s; c_y = tmp->open_y; tmp->open_w = tmp->open_w - s; break; } temp[tmp->ch_length - 1] = new window(n, c_x, c_y, c_w, c_h); tmp->children = temp; } for(int i = 1; i <= n; i++) { tmp = outer.find(i); cout << i << ". "; cout << tmp->width << "x" << tmp->height << " @ ("; cout << tmp->coordx << "," << tmp->coordy << ")" << endl; } exit(0); }