_pouya's blog

By _pouya, history, 2 months ago, In English,

Hello CodeForces Community!

I decided to share every single method i know about Sum query from simple to hard!

so let's start.

1-simple Sum query without any update :

given an array of integers and queries ask you about sum of a range.

prefix_sum O(N + Q)
SparsTable O(Nlog(N))

2-Sum query with index update :

having 2 type of queries one ask about sum in range and one add a value to index i.

Segment_tree O(Nlog(N))
Segment Tree II O(NLog(N))
Binary Indexed Tree (Fenwick tree) O(NLog(N))
Sqrt Decomposition O(Nsqrt(N))

3-Sum query with range update:

2 type of queries one add value in range [L, R] and one sum of range.

Segment Tree (lazy) O(NLog(N))
Sqrt Decomposition O(Nsqrt(N))

If anyone have code of range update for sqrt decomposition i'll be thankful :)

and if anyone have other method or better code i'll be thankful again if he/she share with us :)

i'll add problems soon

In the bleak midwinter...

 
 
 
 
  • Vote: I like it  
  • -18
  • Vote: I do not like it  

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by _pouya (previous revision, new revision, compare).

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by _pouya (previous revision, new revision, compare).

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by _pouya (previous revision, new revision, compare).

»
2 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Nice tutorial :O

Add some problem :P

  • »
    »
    2 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    soon <3

  • »
    »
    2 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    well it was not a tutorial

    more it was a code sharing :D

    but because you said i'll share some good links to learn this data structures.

»
2 months ago, # |
Rev. 2   Vote: I like it +3 Vote: I do not like it

Sum query with range update can be done with 2xfenwick tree.

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

What is mdash in sparse table for simple query code??

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by _pouya (previous revision, new revision, compare).