You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
692 B
C++

#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
int w, h, n, p;
scanf("%d%d%d", &w, &h, &n);
set<int64_t> _s[2] = {{0, w}, {0, h}};
multiset<int64_t> _ms[2] = {{w}, {h}};
for (char op[3]; n--; printf("%lld\n", *_ms[0].rbegin() * *_ms[1].rbegin()))
{
scanf("%s%d", op, &p);
auto &s = _s[*op == 'H'];
auto &ms = _ms[*op == 'H'];
auto it = s.upper_bound(p);
auto len1 = *it - p, len2 = p - *--it;
ms.erase(ms.find(len1 + len2));
s.insert(p), ms.insert(len1), ms.insert(len2);
}
return 0;
}