Mr. Engineer and Mrs. Doctor have decided to rest the summer completely and leave work…
- User
Mr. Engineer and Mrs. Doctor have decided to rest the summer completely and leave work for a while. They have chosen the village of the engineer's father to rest. Both of them are interested in agriculture and plan to farm in the farmland that belongs to Mr. Engineer's father during the holidays. But they have not agreed on the type of product! Mr. Engineer likes to plant strawberries, but Mrs. Doctor prefers to plant turnips. That's why they have decided to divide the land.
Agricultural land can be in the form of a rectangle h x w h×w considered. They are supposed to make divisions using horizontal and vertical jobs and plant turnips or strawberries in each of the parts. In order to make the agricultural land beautiful, they decide to plant the crops in a checkered pattern. It means that the product of any two parts that have a common border (one point alone is not considered a common border) is not the same. The plowing is with Mr. Engineer and the choice of how to plant the crops is with the doctor. (Note that there are only two modes) Mrs. Doctor, who likes turnips more, likes to determine how to plant crops so that the amount of turnips to be planted is maximized.
You have to write a program that will determine how much land the doctor allocates to planting turnips by getting the information about Mr. Engineer's plowings in terms of time, after each plowing that is created.
Description of the image
"The input of the first example is like the picture of the question"
input The first line of input contains three natural numbers in order w w, land width, h h, length of land and q q is the number of sweeps.
in each of q q Next line, first
t ∈ H , V t∈H,V
And then the number p p comes to represent the stretching of a job. In case t t is equal to H Let H be a horizontal plane y
p ( 0 < p < h ) y=p(0<p<h) is drawn and if t t is equal to V, a vertical plane in line x
p ( 0 < p < w ) x=p(0<p<w) is drawn.
It is guaranteed that no two threads are drawn in the same direction.
1 ≤ w , h ≤ 1 0 9 1≤w,h≤10 9
1 ≤ q ≤ 500
000 1≤q≤500 000
output Output included q q is the row that is in the row i The ith of that amount of land area that is taken into consideration i The first field should be planted with turnips, print.
Sub-issues Constraint score subproblem 1 5 q ≤ 500 q≤500 2 5 all the joints are in the same direction (all are horizontal or vertical), q ≤ 5
000 q≤5 000 3 25 q ≤ 5
000 q≤5 000 4 20 all the joints are in the same direction (all are horizontal or vertical) 5 45 without additional restrictions Example Sample entry 1 4 3 2 V1 H2 Plain text Sample output 1 9 7 Plain text Sample input 2 5 5 4 H 3 H2 H 4 H1 Plain text Sample output 2 15 20 15 15 c++
- Assistant