Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <map>
- #include <vector>
- #include <set>
- #include <cmath>
- #include <fstream>
- #include <string>
- using namespace std;
- /*
- #define cin in
- #define cout out
- ifstream in("input.txt");
- ofstream out("output.txt");
- /**/
- #define ll long long
- #define mp make_pair
- set<ll> wSetka;
- set<ll> hSetka;
- map<ll, int> hMapka;
- map<ll, int> wMapka;
- int main()
- {
- int w,h,n;
- cin >> w >> h >> n;
- wSetka.insert(0);
- wSetka.insert(w);
- hSetka.insert(0);
- hSetka.insert(h);
- hMapka.insert(h, 1);
- wMapka.insert(w, 1);
- for (int i = 0; i < n; ++i)
- {
- char c;
- int x;
- cin >> c >> x;
- ll len = 0;
- set<ll>::iterator cur;
- if (c == 'H')
- cur = hSetka.lower_bound(x);
- else
- cur = wSetka.lower_bound(x);
- int beg = *cur;
- cur++;
- len = *cur - beg;
- if (c == 'H')
- {
- hSetka.insert(x);
- if (hMapka[len] == 1)
- hMapka.erase(len);
- else
- hMapka[len]--;
- hMapka[x-beg]++;
- hMapka[x + len - beg]++;
- }
- else
- {
- wSetka.insert(x);
- if (wMapka[len] == 1)
- wMapka.erase(len);
- else
- wMapka[len]--;
- wMapka[x-beg]++;
- wMapka[x + len - beg]++;
- }
- ll width = (*(--hMapka.end())).first;
- ll height = (*(--wMapka.end())).first;
- cout << width * height << "\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement