Skip to main content

Practice · 1 of 4

Occupy the k-th Empty Slot

CHALLENGE
Difficulty: advanced+25 XP

**Bài toán.** n empty slots, q operations: 1 k — occupy the k-th still-empty slot and print its position; 2 p — print 1 if slot p is occupied, else 0. **Constraints:** 1 ≤ n, q ≤ 200 000; k never exceeds the number of empty slots. Op 1 must be O(log n) — the descent walk on empty counts.

Back to lesson: Practice: Fenwick Variant Drills