Broken Device 2
Time limit2sMemory limit512 MB
Anna must encode an integer up to 10^18 into 0/1 arrays sent through a riffle-shuffle device so Bruno can recover it exactly.
- Level
Hard8 of 10
- Topics
- Math, Bit manipulation, Implementation
- Solved
- No attempts yet
Problem
Anna and Bruno are gamble masters. They play a game with D-taro, the dealer of the game.
In this game, Anna and Bruno stay in different rooms. They can communicate only through a broken device. D-taro gives an integer to Anna. Their goal is to send the given integer from Anna to Bruno through the device.
When the game starts, Anna declares an integer between 1 and 2000, inclusive. Then they play rounds. Round () goes as follows.
- D-taro gives an integer to Anna.
- Anna inputs arrays and into the device. Every element of and is either 0 or 1. The two arrays have the same length, which is between 1 and , inclusive.
- Let be the array obtained from and by a riffle shuffle (see below). The device sends to Bruno.
- Bruno sends an integer to D-taro. If this integer equals , Anna and Bruno win the round.
Write programs that implement the strategies of Anna and Bruno so that they win all rounds.
Constraints
.
().