Блог пользователя Jahid

Автор Jahid, 10 лет назад, По-английски

How can I quickly identify a particular problem can easily be solved by BIT? What kinds of problems can be solved by BIT other than range sum calculation & increasing sub-sequence?

  • Проголосовать: нравится
  • +6
  • Проголосовать: не нравится

»
10 лет назад, # |
  Проголосовать: нравится -13 Проголосовать: не нравится

Well, the fact that you need cumulative sums and you can update some element in array, like you have queries sum(l,r) and update(pos,val)

»
10 лет назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

It's also possible to solve range minimum query (only with negative updates) and range maximum query (only with positive updates) with BIT.
Anyway, BIT is like set or vector ... It's just a useful tool! You can use it when you need it. You just have to keep it in your mind this thing exists and be ready to use it.

»
10 лет назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

See this link , for understanding various usage of BIT.
http://zobayer.blogspot.in/2013/11/various-usage-of-bit.html

For problems, follow this link :-
http://ahmed-aly.com/Category.jsp?ID=26

»
10 лет назад, # |
Rev. 4   Проголосовать: нравится +1 Проголосовать: не нравится

You can find the number of inversions in permutation using BIT:

for(int i=N;i>=1;i--)
{
ans+=sum(A[i]);
update(A[i],1);
}

So index i is 1 if number i was already visited, otherwise it's 0. With sum(A[i]) we find the numbers less than A[i], which are on its right. If it's not a permutation, just a sequence with N distinct numbers, you can easy compress them from 1 to N in O(NlogN) using STL sort.

»
10 лет назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

M.Mahdi thanks for your concept :) .. I never knew it .. :( hagu zobayer vai's blog is awesome and thanks to you for your information. :) P_Nyagolov thank you :)

I am trying to solve problem.