by
rectangular grid, where
is the number of columns and
is the number of rows. There are
score multipliers each of which are applied to a specific range of columns or rows. These score multipliers stack, i.e. they are applied on the current score, not base score. This means that two
score multipliers are equivalent to a single
score multiplier. The base score changes depending on the level that is playing on, however the multipliers remain the same.
See the input specification and sample for more details.
The objective of this game is to find a rectangular region where the total score (after multipliers) in the region is equal to the objective score. ) and the objective score (
). While he is playing the game, you will answer
such queries.
Constraints
Total absolute multiplier at any point is guaranteed to be less than .
Variable | Subtask 1 [5%] | Subtask 2 [5%] | Subtask 3 [90%] |
---|---|---|---|
Note: You will have to use fast input methods.
Input Specification
The first line will contain the four space separated integers ,
,
,
.
The next lines are of the following two forms denoting describing the multipliers:
c x y f
– anscore multiplier is applied to columns
.
r x y f
– anscore multiplier is applied to rows
.
The next lines contain two space separated integers,
and
, the base and objective scores respectively.
Output Specification
lines each with a single integer corresponding to the number of rectangles that with the given base score adds up to the objective score.
Sample Input
3 3 3 1
c 2 3 2
c 3 3 4
r 2 3 3
3 72
Sample Output
2
Explanation for Sample Output
With a base score of , the grid has the following scores.
________________________
| \\ C|| | | |
|R \\ || 1 | 2 | 3 |
|=====++=====+=====+=====|
| 1 || 3 | 6 | 24 |
|-----++-----+-----+-----|
| 2 || 9 | 18 | 72 |
|-----++-----+-----+-----|
| 3 || 9 | 18 | 72 |
|_____||_____|_____|_____|
There are only two rectangular regions that have a total score of , the single squares
and
.
Comments
Do I get extra points for having the game installed?