*NOTE: This problem statement contains images that may not display properly if viewed outside of the applet.*
There is an infinite sheet of paper which is divided into 1x1 cells. A cartesian coordinate system exists on the sheet, with its origin at the corner of one of the cells. The X-axis goes from left to right in the positive direction and the Y-axis goes from bottom to top in the positive direction. The axes are parallel to the sides of the cells.
Initially, all the cells are white. You are given a String[] **rectangles**, each element of which represents a rectangular pattern you will draw on the sheet. Each rectangle is formatted "x1 y1 x2 y2 type" (quotes for clarity), where (*x1*, *y1*) is the bottom left corner of the rectangle, (*x2*, *y2*) is the top right corner of the rectangle, and *type* is the number of one of the following patterns:
*Pattern 1:* All cells are colored black.
*Pattern 2:* All cells in odd-numbered rows are colored black (the rows of the rectangle are numbered from bottom to top, starting from 0).
*Pattern 3:* All cells in odd-numbered columns are colored black (the columns of the rectangle are numbered from left to right, starting from 0).
*Pattern 4:* All cells with row and column numbers that are either both odd or both even are colored black.
The pictures below illustrate a rectangle and all the possible patterns:
Return the total number of black cells on the sheet of paper after all the rectangles are drawn. |