Floppy
Time limit1sMemory limit1024 MB
Encode an array of distinct integers into a bit sequence so that range-maximum index queries can be answered from the bits alone.
- Level
Hard8 of 10
- Topics
- Tree, Stack, Bit manipulation
- Solved
- No attempts yet
문제
Roxette, an old tech geek, came across an array of distinct integers. Finding it interesting, she wanted to save the array on her floppy disk. However, her disk has little free space, so she cannot save the whole array. Instead, she plans to save an array of bits that lets her answer any query of the following form:
, where and
In other words, the query returns the index of the maximum value in a given sub-array.
Roxette asks for your help twice. First, she gives you the array, and you tell her which sequence of bits to save on the disk. Second, when she needs answers to some queries, she gives you the bit sequence you chose along with the queries, and you provide the correct answer to each query.
제한
- for all