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

Автор tom, история, 8 лет назад, По-английски

Hello everyone!

I've been thinking about solution to the following problem for few days and didn't come up with any reasonable idea. Could you help me out?

You're given array of n elements and q queries. Every query is one of two type:

1) Reverse interval [l, r], e.g. for array 1 2 3 4 5 6 and query [2, 5] we end up with 1 5 4 3 2 6.

2) Ask for sum on interval [l, r].

Thanks and have a nice Sunday.

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

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

This is quite simple to do using treaps and lazy propagation on them. You can find resources by googling.

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

can you post the link to the question?

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

If you want a solution not using treaps then read Burunduk1's lecture note. (The Split and Rebuild variant)