Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <map>
  4. #include <vector>
  5. #include <set>
  6. #include <cmath>
  7. #include <fstream>
  8. #include <string>
  9.  
  10. using namespace std;
  11.  
  12. /*
  13. #define cin in
  14. #define cout out
  15. ifstream in("input.txt");
  16. ofstream out("output.txt");
  17. /**/
  18.  
  19. #define ll long long
  20. #define mp make_pair
  21.  
  22. set<ll> wSetka;
  23. set<ll> hSetka;
  24. map<ll, int> hMapka;
  25. map<ll, int> wMapka;
  26.  
  27. int main()
  28. {
  29. int w,h,n;
  30. cin >> w >> h >> n;
  31.  
  32. wSetka.insert(0);
  33. wSetka.insert(w);
  34. hSetka.insert(0);
  35. hSetka.insert(h);
  36. hMapka.insert(h, 1);
  37. wMapka.insert(w, 1);
  38.  
  39. for (int i = 0; i < n; ++i)
  40. {
  41. char c;
  42. int x;
  43. cin >> c >> x;
  44. ll len = 0;
  45. set<ll>::iterator cur;
  46. if (c == 'H')
  47. cur = hSetka.lower_bound(x);
  48. else
  49. cur = wSetka.lower_bound(x);
  50.  
  51.  
  52. int beg = *cur;
  53. cur++;
  54. len = *cur - beg;
  55.  
  56. if (c == 'H')
  57. {
  58. hSetka.insert(x);
  59. if (hMapka[len] == 1)
  60. hMapka.erase(len);
  61. else
  62. hMapka[len]--;
  63. hMapka[x-beg]++;
  64. hMapka[x + len - beg]++;
  65. }
  66. else
  67. {
  68. wSetka.insert(x);
  69.  
  70. if (wMapka[len] == 1)
  71. wMapka.erase(len);
  72. else
  73. wMapka[len]--;
  74. wMapka[x-beg]++;
  75. wMapka[x + len - beg]++;
  76. }
  77.  
  78. ll width = (*(--hMapka.end())).first;
  79. ll height = (*(--wMapka.end())).first;
  80.  
  81. cout << width * height << "\n";
  82. }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement