A grid is subdivided into right-angled triangles with an arbitrary base (horizontal) and height (vertical). In the images below, the base of each triangle is
Given a starting point (the

The diagram to the right shows a right-angled triangle at point
If we reverse the polarity on those tiles we will change the color.
As we continue to define shapes we will continue to reverse the polarity on all tiles that lie completely within the shapes, and we will change their colors.
The input will contain
The first line of each test case consists of two integers
The second line of the test case is the sequence of colors (e.g.m Red
, Blue
, SunshineYellow
, etc.). The sequence will contain between
The third line of each test case is an integer
T X Y Tb
= Triangle with the right angle at point and a base of tiles, where andR X Y W H
= Rectangle with a corner at point , a width of tiles and a height of tiles, where and
The last
For each unique color in the sequence, you must output the number of points that will end up that color after the appropriate tiles have had their polarities reversed once for each of the shapes in the list. The colors and counts should be printed on a single line using the exact format shown below. The order in which you output the colors on each line is not important.
Note that in the sample input, there are
Sample Input
1 3
White Black
10
R 78 66 19 2
T 18 96 8
T 2 78 1
R 87 78 66 2
R 33 45 55 11
R 50 36 8 3
T 59 72 40
R 19 15 67 6
T 51 54 17
R 98 54 16 28
123 60
33 64
196 177
99 145
88 162
3 3
White Black
10
R 45 63 8 23
R 42 18 19 21
R 45 42 28 30
R 18 48 19 12
R 3 63 22 4
T 75 72 28
T 84 72 22
T 42 0 22
T 78 57 29
R 24 36 25 6
108 44
24 164
177 40
122 82
115 37
3 2
White Black
10
T 75 44 27
R 12 36 6 26
T 21 12 4
T 3 38 22
T 45 40 17
T 75 32 30
T 33 80 1
R 6 42 19 49
T 15 92 24
R 72 66 5 16
172 120
195 82
61 99
140 169
132 155
Sample Output
Black:1 White:4
Black:1 White:4
Black:0 White:5
Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org
Comments