fork download
  1. struct line
  2. {
  3. long long a,b;
  4. }it[4000010];
  5.  
  6. long long get(line a,long long x)
  7. {
  8. return a.a*x+a.b;
  9. }
  10.  
  11.  
  12. // update line x to out set
  13. void update(long long p,long long l,long long r,line x)
  14. {
  15. if (!al[p]) q.push(p),al[p]=1;
  16. line y=it[p];
  17. if (get(y,l)>=get(x,l) and get(y,r)>=get(x,r))
  18. return;
  19. if (get(y,l)<=get(x,l) and get(y,r)<=get(x,r))
  20. {
  21. it[p]=x;
  22. return;
  23. }
  24. long long m=(l+r)/2;
  25. if (get(y,l)>=get(x,l) and get(y,m)>=get(x,m))
  26. {
  27. update(p*2+1,(l+r)/2+1,r,x);
  28. return;
  29. }
  30. if (get(y,l)<=get(x,l) and get(y,m)<=get(x,m))
  31. {
  32. it[p]=x;
  33. update(p*2+1,(l+r)/2+1,r,y);
  34. return;
  35. }
  36. if (get(y,r)>=get(x,r) and get(y,m+1)>=get(x,m+1))
  37. {
  38. update(p*2,l,(l+r)/2,x);
  39. return;
  40. }
  41. if (get(y,r)<=get(x,r) and get(y,m+1)<=get(x,m+1))
  42. {
  43. it[p]=x;
  44. update(p*2,l,(l+r)/2,y);
  45. return;
  46. }
  47. }
  48.  
  49.  
  50. // get maximum value of at coordinate a
  51. long long get_val(long long p,long long l,long long r,long long a)
  52. {
  53. if (r<a or l>a) return -1e18;
  54. long long x=get(it[p],a);
  55. if (l==r) return x;
  56. x=max(x,get_val(p*2,l,(l+r)/2,a));
  57. x=max(x,get_val(p*2+1,(l+r)/2+1,r,a));
  58. return x;
  59. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘void update(long long int, long long int, long long int, line)’:
prog.cpp:15:7: error: ‘al’ was not declared in this scope
  if (!al[p]) q.push(p),al[p]=1;
       ^~
prog.cpp:15:14: error: ‘q’ was not declared in this scope
  if (!al[p]) q.push(p),al[p]=1;
              ^
prog.cpp: In function ‘long long int get_val(long long int, long long int, long long int, long long int)’:
prog.cpp:56:34: error: ‘max’ was not declared in this scope
  x=max(x,get_val(p*2,l,(l+r)/2,a));
                                  ^
stdout
Standard output is empty