Serie A champions piece w*h glass its n Split times the maximum output for each division pane area Vertical or horizontal
With two sets of storage each time the location of the split can be more convenient to each split to produce and disappear the long-width of each partition after the remaining maximum length of the product is the answer.
#include <bits/stdc++.h>using namespace Std;const int N = 200005;typedef Long Long ll;set<int>::iterator I, J; Set<int> ve, ho; Record the position of all edges int wi[n], hi[n]; Record the presence of the edge Long value void Cut (set<int> &s, int *a, int p) {S.insert (p), i = j = S.find (p); -------++j,--a[*j-*i]; Remove the separated long-width ++a[p-*i], ++a[*j-p]; A new generation of two}int main () {int W, n, H, p, MW, MH; Char s[10]; while (~SCANF ("%d%d%d", &w, &h, &n)) {memset (WI, 0, sizeof (WI)), memset (Hi, 0, sizeof (HI)); Ve.clear (), ho.clear (); Ve.insert (0), Ho.insert (0); Ve.insert (W), Ho.insert (h); WI[W] = hi[h] = 1; MW = W, MH = h; while (n--) {scanf ("%s%d", S, &p); if (s[0] = = ' V ') cut (ve, WI, p); else Cut (ho, Hi, p); while (!WI[MW])--MW; while (!HI[MH])--mh; printf ("%lld\n", LL (MW) *ll (MH)); }} return 0;}
C. Glass Carving
Leonid wants to become a glass carver (the person who creates beautiful artworks by cutting the glass). He already has a rectangular wmm ? x? h mm sheet of glass, a diamond glass cutter and lots of enthusiasm. What the He lacks is understanding by and how carve.
In order waste time, he decided to practice the technique of carving. To does 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.
After all cut Leonid tries to determine, the largest of the currently available glass has. Since there appear more and more fragments, this question takes him + and more time and distracts him from the Fascinat ing process.
Leonid offers to divide the labor-he would cut glass, and you'll calculate the area of the maximum fragment after each Cut. Do you agree?
Input
The first line contains three integers w,? H,? n (2?≤? ) W,? h. ≤?200?000, 1?≤? N? ≤?200?000).
NextNLines contain the descriptions of the cuts. Each description have the formH yOrV x. In the first case Leonid makes the horizontal cut at the distanceyMillimeters (1?≤? y? ≤? h?-? 1) from the lower edge of the original sheet of glass. In the second case Leonid makes a vertical cut at distancex(1?≤? x? ≤? W?-? 1) millimeters from the left edge of the original sheet of glass. It is guaranteed this Leonid won ' t make both identical cuts.
Output
After each cut, print on a, the area of the maximum available glass fragment in mm2.
Sample Test (s) input
4 3 4H 2V 2V 3V 1
Output
8442
Input
7 6 5H 4V 3V 5H 2V 1
Output
28161264
Note
Picture for the first sample test:
Picture for the second sample test:
Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.
Codeforces 527C Glass Carving (Set)