fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. set<int> v;
  7. set<int> h;
  8. set<int>::iterator it;
  9. multiset<int> v1;
  10. multiset<int> h1;
  11. int m1[200005];
  12. int m2[200005];
  13. multiset<int>::iterator it1,it2;
  14. int i;
  15. int n;
  16. int l;
  17. int b;
  18. int x;
  19. char c;
  20. int frst;
  21. int last;
  22.  
  23. cin>>b>>l>>n;
  24. m1[0] = l;
  25. m2[0] = b;
  26. v.insert(0);
  27. h.insert(0);
  28. v1.insert(b);
  29. h1.insert(l);
  30.  
  31. while(n--) {
  32. scanf(" %c%d",&c,&x);
  33. if(c == 'H') {
  34. x = l-x;
  35. it = lower_bound(h.begin(),h.end(),x);
  36. //cout<<"sss"<<endl;
  37. it--;
  38. frst = *it;
  39. last = m1[frst];
  40. // cout<<frst<<' '<<last<<endl;
  41. h.erase(it);
  42. //cout<<frst<<' '<<last-x<<' '<<last-x<<' '<<last<<endl;
  43. h.insert(frst);
  44. m1[frst] = x;
  45. h.insert(x);
  46. m1[x] = last;
  47. it1 = find(h1.begin(),h1.end(),last-frst);
  48. h1.erase(it1);
  49. h1.insert(abs(x-frst));
  50. h1.insert(abs(last-x));
  51.  
  52. }
  53. else {
  54.  
  55. it = lower_bound(v.begin(),v.end(),x);
  56. it--;
  57. frst = *it;
  58. last = m2[frst];
  59. //cout<<frst<<' '<<last<<endl;
  60. v.erase(it);
  61. //cout<<frst<<' '<<last-x<<' '<<last-x<<' '<<last<<endl;
  62. v.insert(frst);
  63. m2[frst] = x;
  64. v.insert(x);
  65. m2[x] = last;
  66. it1 = find(v1.begin(),v1.end(),last-frst);
  67. v1.erase(it1);
  68. v1.insert(abs(x-frst));
  69. v1.insert(abs(last-x));
  70.  
  71. }
  72. it1 = v1.end();
  73. it1--;
  74. it2 = h1.end();
  75. it2--;
  76. printf("%I64d\n",(long long)*it1 * (long long)*it2);
  77.  
  78. }
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86. }
  87.  
Success #stdin #stdout 0s 4920KB
stdin
Standard input is empty
stdout
Standard output is empty