Rectangle Division

Limits: 3.5s, 512 MB

You are given a rectangle which is parallel to the coordinate axis. The lower left coordinate is (x,y) and the length of two sides are r and c ( described in figure ). You can easily construct the rectangle by connecting these 4 points { (x,y) , (x+c,y) , (x+c,y+r) , (x,y+r) } in anti-clockwise order. Fig : A line drawn form (px,py) dividing the rectangle into two equal parts (according to area). Note that, the figure may not be mathematically accurate. It is used just for understanding purposes.

This is a companion discussion topic for the original entry at