fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  5. #define endl "\n"
  6. #define ff first
  7. #define ss second
  8. #define mp make_pair
  9. #define pb push_back
  10.  
  11. #define trace1(x) cerr<<#x<<": "<<x<<endl
  12. #define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  13. #define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  14. #define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  15. #define trace5(a, b, c, d, e) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  16. #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  17.  
  18. typedef long long ll;
  19.  
  20. const int N=1e6+5;
  21.  
  22. int n, q;
  23. long long a[N];
  24. long long bit[N][2];
  25.  
  26. void update(int i, int id, int x)
  27. {
  28. while(i<=n)
  29. {
  30. bit[i][id]+=x;
  31. i+=(i&(-i));
  32. }
  33. }
  34.  
  35. long long prefsum(int i, int id)
  36. {
  37. long long ans=0;
  38. while(i>0)
  39. {
  40. ans+=bit[i][id];
  41. i-=(i&(-i));
  42. }
  43. return ans;
  44. }
  45.  
  46. long long rsum(int i, int j, int id)
  47. {
  48. return prefsum(j, id) - prefsum(i-1, id);
  49. }
  50.  
  51. int main()
  52. {
  53. cin>>n>>q;
  54. for(int i=1;i<=n;i++)
  55. {
  56. cin>>a[i];
  57. update(i, a[i]%2, a[i]);
  58. }
  59. for(int i=1;i<=q;i++)
  60. {
  61. int type;
  62. cin>>type;
  63. if(type==1)
  64. {
  65. int x,y;
  66. cin>>x>>y;
  67. update(x, a[x]%2, -1*a[x]);
  68. a[x]+=y;
  69. update(x, a[x]%2, a[x]);
  70. }
  71. else
  72. {
  73. int L,R,x;
  74. cin>>L>>R>>x;
  75. cout<<rsum(L, R, x)<<endl;
  76. }
  77. }
  78. return 0;
  79. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:1:25: fatal error: bits/stdc++.h: No such file or directory
 #include <bits/stdc++.h>
                         ^
compilation terminated.
stdout
Standard output is empty