fork download
  1. void upd(int node,int l,int r,int val)
  2. {
  3. tree[node] = (r - l + 1) * val;
  4. lazy[node] = val;
  5. }
  6.  
  7. void propagate(int node,int l,int r)
  8. {
  9. if (lazy[node] == -1) return;
  10. int mid = (l + r) >> 1;
  11. upd(node * 2,l,mid,lazy[node]);
  12. upd(node * 2 + 1,mid + 1,r,lazy[node]);
  13. lazy[node] = -1;
  14. }
  15.  
  16. void rangeUpdate(int node,int nodeL,int nodeR,int queryL,int queryR,int val)
  17. {
  18. if (queryL > nodeR) return;
  19. if (queryL <= nodeL && nodeR <= queryR)
  20. {
  21. upd(node,l,r,val);
  22. return;
  23. }
  24. propagate(node,nodeL,nodeR);
  25. int mid = (nodeL + nodeR) >> 1;
  26. rangeUpdate(node * 2,nodeL,mid,queryL,queryR,val);
  27. rangeUpdate(node * 2 + 1,mid + 1,nodeR,queryL,queryR,val);
  28. tree[node] = tree[node * 2] + tree[node * 2 + 1];
  29. }
  30.  
  31. int rangeQuery(int node,int nodeL,int nodeR,int queryL,int queryR,int val)
  32. {
  33. if (queryL > nodeR) return;
  34. if (queryL <= nodeL && nodeR <= queryR) return tree[node];
  35. propagate(node,nodeL,nodeR);
  36. int mid = (nodeL + nodeR) >> 1;
  37. return rangeQuery(node * 2,nodeL,mid,queryL,queryR) + rangeQuery(node * 2 + 1,mid + 1,nodeR,queryL,queryR);
  38. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘void upd(int, int, int, int)’:
prog.cpp:3:2: error: ‘tree’ was not declared in this scope
  tree[node] = (r - l + 1) * val;
  ^~~~
prog.cpp:4:2: error: ‘lazy’ was not declared in this scope
  lazy[node] = val;
  ^~~~
prog.cpp: In function ‘void propagate(int, int, int)’:
prog.cpp:9:6: error: ‘lazy’ was not declared in this scope
  if (lazy[node] == -1) return;
      ^~~~
prog.cpp:11:21: error: ‘lazy’ was not declared in this scope
  upd(node * 2,l,mid,lazy[node]);
                     ^~~~
prog.cpp: In function ‘void rangeUpdate(int, int, int, int, int, int)’:
prog.cpp:21:12: error: ‘l’ was not declared in this scope
   upd(node,l,r,val);
            ^
prog.cpp:21:14: error: ‘r’ was not declared in this scope
   upd(node,l,r,val);
              ^
prog.cpp:28:2: error: ‘tree’ was not declared in this scope
  tree[node] = tree[node * 2] + tree[node * 2 + 1];
  ^~~~
prog.cpp: In function ‘int rangeQuery(int, int, int, int, int, int)’:
prog.cpp:33:22: error: return-statement with no value, in function returning ‘int’ [-fpermissive]
  if (queryL > nodeR) return;
                      ^~~~~~
prog.cpp:34:49: error: ‘tree’ was not declared in this scope
  if (queryL <= nodeL && nodeR <= queryR) return tree[node];
                                                 ^~~~
prog.cpp:37:52: error: too few arguments to function ‘int rangeQuery(int, int, int, int, int, int)’
  return rangeQuery(node * 2,nodeL,mid,queryL,queryR) + rangeQuery(node * 2 + 1,mid + 1,nodeR,queryL,queryR);
                                                    ^
prog.cpp:31:5: note: declared here
 int rangeQuery(int node,int nodeL,int nodeR,int queryL,int queryR,int val)
     ^~~~~~~~~~
prog.cpp:37:107: error: too few arguments to function ‘int rangeQuery(int, int, int, int, int, int)’
  return rangeQuery(node * 2,nodeL,mid,queryL,queryR) + rangeQuery(node * 2 + 1,mid + 1,nodeR,queryL,queryR);
                                                                                                           ^
prog.cpp:31:5: note: declared here
 int rangeQuery(int node,int nodeL,int nodeR,int queryL,int queryR,int val)
     ^~~~~~~~~~
stdout
Standard output is empty