AK47
Time limit4.7sMemory limit1024 MB
Find the two treasure zones among N zones in a row using at most 47 range queries, where a query reacts only when exactly one treasure lies in the range.
- Level
Medium7 of 10
- Topics
- Binary search, Bit manipulation, Implementation
- Solved
- No attempts yet
문제
Gunshots ring out every night in a neighborhood where zones are lined up in a row. Two different zones hold treasure, and the rest have bombs installed. Isaac needs money to send his mother to a nursing home, so he decides to steal both treasures. Entering a zone with a bomb sets it off, so Isaac must pinpoint the exact two zones that hold the treasures.
The treasures react to screams. Grandma can make a scream whose sound reaches a contiguous range of zones in the row. A treasure reacts only when exactly one treasure lies within the range the sound reaches. If no treasure is there, nothing reacts and no reaction is felt. If both treasures are there, their reactions overlap and no reaction is felt.
Grandma can make at most 47 screams. Help Grandma so Isaac can steal both treasures.