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

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

Link: https://toph.co/p/cut-the-rope Which algorithm suits this kind of problems? I tried segment tree.

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

»
9 лет назад, скрыть # |
 
Проголосовать: нравится +25 Проголосовать: не нравится

A treap (or any balanced binary search tree) will be enough.

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

First, find out all lengths of ropes that would appear during process (for example, keep sets of cut points and lengths of ropes). After that, you can use coordinate compression and segment-sum, point-update segment tree that keeps number of ropes of given length. For "cut" queries just do three update queries, for "k-th by length" do tree descend to find smallest length l that there are at least k ropes of length l or less.