fork download
  1. #include <bits/stdc++.h>
  2. #define pii pair<int, int>
  3. #define rep(i,a,b) for(i=a;i<b;++i)
  4. #define repi(i,a,b) for(int i=a;i<b;++i)
  5. #define F first
  6. #define S second
  7. using namespace std;
  8. long long int ans=0;
  9.  
  10. set<int> cutv;
  11. set<int> cuth;
  12. map<int,int>maxw;
  13. map<int,int>maxh;
  14. int w,h,n;
  15. int main() {
  16. // your code goes here
  17. ios::sync_with_stdio(false);
  18. cutv.insert(0);
  19. cuth.insert(0);
  20. cin>>w>>h>>n;
  21. cutv.insert(w);
  22. cuth.insert(h);
  23.  
  24. maxw[w]++;
  25. maxh[h]++;
  26. string ty;
  27. int pos;
  28. repi(i,0,n)
  29. {
  30. cin>>ty;
  31. cin>>pos;
  32. if(ty[0]=='V')
  33. {
  34. set<int>::iterator up = cutv.lower_bound(pos);
  35. set<int>::iterator down = up;
  36. --down;
  37.  
  38. auto it = maxw.find((*up - *down));
  39. (it->second)--;
  40. if(it->second==0)maxw.erase(it);
  41. maxw[*up-pos]++;
  42. maxw[pos-*down]++;
  43. cutv.insert(pos);
  44. cout<<(*maxw.rbegin()).first * (long long)(*maxh.rbegin()).first<<endl;
  45.  
  46. }
  47. else
  48. {
  49. set<int>::iterator up = cuth.lower_bound(pos);
  50. set<int>::iterator down = up;
  51. --down;
  52.  
  53. auto it = maxh.find((*up - *down));
  54. (it->second)--;
  55. if(it->second==0)maxh.erase(it);
  56. maxh[*up-pos]++;
  57. maxh[pos-*down]++;
  58. cuth.insert(pos);
  59. cout<<(*maxh.rbegin()).first * (long long)(*maxw.rbegin()).first <<endl;
  60. }
  61. }
  62. return 0;
  63. }
Success #stdin #stdout 0s 3284KB
stdin
7 6 5
H 4
V 3
V 5
H 2
V 1
stdout
28
16
12
6
4