Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int read(int idy, int idx){
- int sum = 0;
- while(idy>0){
- int tmp = idx;
- while(idx>0){
- sum += tree[idy][idx];
- idx -= (idx&-idx);
- }
- idx = tmp;
- idy -= (idy&-idy);
- }
- return sum;
- }
- void update(int idy, int idx, int val){
- while(idy<=mx){
- int tmp = idx;
- while(idx<=mx){
- tree[idy][idx] += val;
- idx += (idx&-idx);
- }
- idx = tmp;
- idy += (idy&-idy);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement