codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

527C.md (2400B)


      1 Source: https://codeforces.com/problemset/problem/527/C
      2 
      3 C. Glass Carving
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Leonid wants to become a glass carver (the person who creates beautiful artworks by cutting the glass). He already has a rectangular *w* mm  ×  *h* mm sheet of glass, a diamond glass cutter and lots of enthusiasm. What he lacks is understanding of what to carve and how.
     22 
     23 In order not to waste time, he decided to practice the technique of carving. To do this, he makes vertical and horizontal cuts through the entire sheet. This process results in making smaller rectangular fragments of glass. Leonid does not move the newly made glass fragments. In particular, a cut divides each fragment of glass that it goes through into smaller fragments.
     24 
     25 After each cut Leonid tries to determine what area the largest of the currently available glass fragments has. Since there appear more and more fragments, this question takes him more and more time and distracts him from the fascinating process.
     26 
     27 Leonid offers to divide the labor — he will cut glass, and you will calculate the area of the maximum fragment after each cut. Do you agree?
     28 
     29 Input
     30 
     31 The first line contains three integers *w*, *h*, *n* (2 ≤ *w*, *h* ≤ 200 000, 1 ≤ *n* ≤ 200 000).
     32 
     33 Next *n* lines contain the descriptions of the cuts. Each description has the form *H* *y* or *V* *x*. In the first case Leonid makes the horizontal cut at the distance *y* millimeters (1 ≤ *y* ≤ *h* - 1) from the lower edge of the original sheet of glass. In the second case Leonid makes a vertical cut at distance *x* (1 ≤ *x* ≤ *w* - 1) millimeters from the left edge of the original sheet of glass. It is guaranteed that Leonid won't make two identical cuts.
     34 
     35 Output
     36 
     37 After each cut print on a single line the area of the maximum available glass fragment in mm2.
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 4 3 4  
     45 H 2  
     46 V 2  
     47 V 3  
     48 V 1
     49 ```
     50 
     51 Output
     52 
     53 ```
     54 8  
     55 4  
     56 4  
     57 2
     58 ```
     59 
     60 Input
     61 
     62 ```
     63 7 6 5  
     64 H 4  
     65 V 3  
     66 V 5  
     67 H 2  
     68 V 1
     69 ```
     70 
     71 Output
     72 
     73 ```
     74 28  
     75 16  
     76 12  
     77 6  
     78 4
     79 ```
     80 
     81 Note
     82 
     83 Picture for the first sample test:
     84 
     85  ![](https://espresso.codeforces.com/357324961464c49c9a309a3d48f6a660b64b1522.png)  Picture for the second sample test:  ![](https://espresso.codeforces.com/c8483b396b150f751303889eca8d83f5a23e4bc6.png)