## MWC '15 #4 P5: Arts and Crafts

View as PDF

Points: 10 (partial)
Time limit: 0.6s
Memory limit: 256M

Author:
Problem type

icicreampoph is doing some arts and crafts. Hypothetically speaking, he is cutting horizontal and vertical lines on a by sheet of paper. He has two tools, a pair of scissors and a paper cutter. The paper cutter will always cut the whole sheet (from one end to another). With the scissors though, he can choose how deep to cut the paper. Unfortunately, the paper cutter is set up to only cut vertically, and thus, he will only use the scissors to cut horizontally. Before he actually cuts the paper, he wants to know how many pieces of paper he will end up with after the cuts.

A piece of paper is freed when all 4 sides of the rectangular area is cut (including the original edges of the paper). He may cut multiple times at the same spot. When this happens, infinitely small pieces of paper will not be created, i.e., the longer cut takes precedence.

#### Input Specification

Three space separated integers, , and .

lines follow, of the form:

• h s d a horizontal cut of depth starting above the bottom of the piece of paper.
• v s a vertical cut from the top to the bottom starting to the right of the left edge of the sheet.

#### Constraints

Note: fast input may be required.

#### Output Specification

The number of pieces of paper that icicreampoph will end up with after performing the cuts.

#### Sample Input

3 4 6
h 3 4
h 1 3
v 2

#### Sample Output

5

#### Explanation for Sample Output

The cuts are shown in the picture below. The gold numbers show the pieces of paper.