Broken Device
Time limit2sMemory limit512 MB
Build a 150-bit sequence for a 64-bit integer X so the receiver can recover X even when up to 40 unknown positions are forced to 0.
- Level
Hard8 of 10
- Topics
- Bit manipulation, Math, Combinatorics
- Solved
- No attempts yet
Problem
Anna and Bruno are archaeologists. They are investigating ruins in Iran.
Their tasks are as follows: Anna visits the ruins and discovers artifacts, and Bruno analyzes the results at the base camp.
Their investigation is scheduled for (= 1000) days. Every day, Anna sends the day's result to Bruno with a communication device. The result for each day is an integer .
Anna can use the communication device once per day only. It can send a sequence of length (= 150) consisting of 0s and 1s.
However, the device is broken. The sequence of length has several broken positions. At a broken position, the device always sends 0, regardless of the value Anna sets. Anna can see the broken positions when she sends a sequence, but Bruno does not know them. The broken positions and their number can change every day.
There is a danger that the investigation will be delayed. You are a candidate for the international programming contest in Iran, so Anna and Bruno ask you to write a program that sends the results of their investigation.
Write two programs that make the communication between Anna and Bruno work.
- The first program takes the sequence length , the integer to send , the number of broken positions , and the broken positions , and sets the sequence that Anna sends.
- The second program takes the sequence that Bruno receives and recovers the integer .
At a working position, and have the same value. At a broken position, always has the value 0 regardless of the value of .
Input
The sample grader reads the following data from standard input.
- The first line contains an integer .
- Then, the information of queries is given.
- The information of each query consists of two lines.
- The first line contains three space-separated integers , , . This means the length of the sequence to send is , the integer Anna sends is , and there are broken positions.
- The second line contains space-separated integers . This means that for each (), the -th position in the sequence is broken.
Output
When the program terminates successfully, the sample grader writes the following information to standard output. (Quotation marks are not actually written.)
- If your program is judged as Wrong Answer, the grader writes the type in the form
Wrong Answer [1], and your program is terminated. - If no call to
Annais judged as Wrong Answer, the grader writesAcceptedand the value of . For the value of , see Scoring.
If your program falls under several types of Wrong Answer, the grader reports only one of them.
Constraints
- .
- .
- .
- .
- ().
- ().