taratam's blog

By taratam, 8 years ago, In English
 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

»
8 years ago, # |
  Vote: I like it +6 Vote: I do not like it

Give a better title to this blog. CodeChef has thousands of problems, should we have thousands of blogs with same title?

»
8 years ago, # |
  Vote: I like it 0 Vote: I do not like it

segment tree lazy propagation.

struct Value {
    int sum[3];
    void Increase() {
       int t = sum[2];
       for (int i = 1; i < 3; ++i) sum[i] = sum[i - 1];
       sum[0] = t; 
    }
    Value operator + (Value b) {
        Value res;
        for (int i = 0; i < 3; ++i) res.sum[i] = sum[i] + b.sum[i];
        return res;  
    }
};