fork(2) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int MAXN = 100000, MAXM = 100000;
  4. int n, m;
  5. int a[MAXN + 9], b[MAXN + 9];
  6. int tp[MAXM + 9], l[MAXM + 9], r[MAXM + 9], v[MAXM + 9];
  7. int A, B;
  8.  
  9. int main()
  10. {
  11. ifstream cin("vmellip.inp");
  12. ofstream cout("vmellip.ans");
  13. ios_base::sync_with_stdio(false);
  14. cin.tie(NULL);
  15. cin >> n >> m;
  16. for(int i = 1; i <= n; i++)
  17. {
  18. cin >> a[i] >> b[i];
  19. }
  20. for(int i = 1; i <= m; i++)
  21. {
  22. cin >> tp[i];
  23. if(tp[i] <= 4)
  24. {
  25. cin >> l[i] >> r[i] >> v[i];
  26. }
  27. else
  28. {
  29. cin >> l[i] >> r[i];
  30. }
  31. }
  32. cin >> A >> B;
  33. for(int i = 1; i <= m; i++)
  34. {
  35. if(tp[i] == 1)
  36. {
  37. for(int j = l[i]; j <= r[i]; j++)
  38. {
  39. if(a[j] > 0 && a[j] <= A)
  40. {
  41. a[j] = v[i];
  42. }
  43. }
  44. }
  45. else if(tp[i] == 2)
  46. {
  47. for(int j = l[i]; j <= r[i]; j++)
  48. {
  49. if(b[j] > 0 && b[j] <= B)
  50. {
  51. b[j] = v[i];
  52. }
  53. }
  54. }
  55. else if(tp[i] == 3)
  56. {
  57. for(int j = l[i]; j <= r[i]; j++)
  58. {
  59. if(a[j] > 0 && a[j] <= A)
  60. {
  61. a[j] += v[i];
  62. }
  63. }
  64. }
  65. else if(tp[i] == 4)
  66. {
  67. for(int j = l[i]; j <= r[i]; j++)
  68. {
  69. if(b[j] > 0 && b[j] <= B)
  70. {
  71. b[j] += v[i];
  72. }
  73. }
  74. }
  75. else if(tp[i] == 5)
  76. {
  77. long long ans = 0;
  78. for(int j = l[i]; j <= r[i]; j++)
  79. {
  80. if(a[j] > 0 && a[j] <= A && b[j] > 0 && b[j] <= B)
  81. {
  82. ans += (long long)a[j] * b[j];
  83. }
  84. }
  85. cout << ans << "\n";
  86. }
  87. else
  88. {
  89. int ans = 0;
  90. for(int j = l[i]; j <= r[i]; j++)
  91. {
  92. if(a[j] > 0 && a[j] <= A && b[j] > 0 && b[j] <= B)
  93. {
  94. ans++;
  95. }
  96. }
  97. cout << ans << "\n";
  98. }
  99. }
  100. return 0;
  101. }
  102.  
Success #stdin #stdout 0s 5812KB
stdin
Standard input is empty
stdout
Standard output is empty