How to use Splay Tree to solve this problem?

Правка en2, от thanhnhan.gl, 2016-05-23 08:59:01

My problem is: Given a sequence of integers (a_n): a_1, a_2, ..., a_n. We do Q queries, each of them (l, r) requires reverse elements from a_l to a_r.

For examples, Given a sequence: 2, 3, 4, 5. The query (1, 3) changes the sequence into 4, 3, 2, 5.

After performing Q queries, the problem asks us to print out the modified sequence.

How to solve this problem, if n and Q are large integers (such as 10^5)?

I hear that the solution uses an approach of Splay Tree.

Please help me and thank you.

Теги splay tree

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский thanhnhan.gl 2016-05-23 09:03:49 1 Tiny change: 'or examples,\nGiven a' -> 'or example,\nGiven a'
en2 Английский thanhnhan.gl 2016-05-23 08:59:01 13
en1 Английский thanhnhan.gl 2016-05-23 08:57:58 551 Initial revision (published)