#P1942. 词编码
词编码
Description
A transmitter sends words consisting of and through a channel. At the other end, a receiver can use special techniques to recover the original words. Each original word consists only of and , and every original word has length . After passing through the channel, exactly one of the following may happen to a word:
- Any single is replaced by .
- Any single symbol is deleted.
- A symbol ( or ) is inserted at any position.
- No change.
We know that every original word has the following property: the sum of the position numbers of the s is a multiple of , or equals .
Input Format
The first line contains a positive integer .
Then follow several lines (not necessarily lines!), each containing one word after passing through the channel, one word per line.
Please read until the end of file:
- For C++
std::cin, you can usewhile (std::cin >> s) {/* ... */}, wheresis a variable of typestd::string. - For C/C++
scanf, you can usewhile (scanf("%s", s) == 1) {/* ... */}, wheresis a variable of typechar*. - For other input functions, please consult their documentation for how to read until EOF.
It is guaranteed that the number of words does not exceed .
Output Format
Your program should print the original words, one per line.
If there are multiple valid originals, choose the best one in the following order and output that best one:
- Prefer by operation in the order: operation → operation → operation → operation .
- Within the same operation, prefer the one with the operation position from left to right.
- For operation inserting at the same position, inserting is preferred over inserting .
If there is no solution, output .
4
0000
011
1011
11011
0000
0110
1001
1111
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号