#P3982. 龙盘雪峰信息解析器

龙盘雪峰信息解析器

Description

Messages from Longpan Snow Peak are encrypted into complex codes. We need you to write a program that deciphers these codes according to the rules below and translates them into text.

The code is a continuous string of binary digits (only 0 0 and 1 1 ; when adding, carry 1 1 whenever it reaches 2 2 ; each 0 0 or 1 1 occupies one character). Every eight characters form one unit (this is also a rule).

Each unit follows these rules:

  1. If the first three characters are 101 101 , the unit represents a letter A-Z A\text{-}Z . The code for A A is 10100000 10100000 , the code for C C is 10100010 10100010 . The 26 26 uppercase letters are arranged in alphabetical order following this pattern, each corresponding to a unique binary code.
  2. If the first three characters are 111 111 , the unit translates to a space.
  3. If the first character is 0 0 , then the unit represents a number to be added to the number represented by the next unit. During this addition, convert these two units to decimal, then divide each by 2 2 and discard the remainder before adding. After the addition, the sum is the translation result for these two units (the result is expressed in decimal). Both of these units are then considered fully translated (see Sample 3 3 ).

For safety, Longpan Snow Peak often sends “fake code,” which does not follow the rules above. If fake code appears, only output Error.

Input Format

The input contains a single line with a continuous code string (length does not exceed 171111 171111 characters). No spaces will appear, and the input is guaranteed to be non-empty.

Output Format

Output a single line containing the string produced by translating the binary code according to the rules above.

If the binary code contains any fake code, only output Error.

1010000011100000101011111010100010100110
A PIG
1
Error
0000001000000010000000100000001010100000
22A
IOIOOOOI
Error

Hint

Explanation for Sample 1 1 :

10100000 10100000 represents A A . The next unit begins with 111 111 , which translates to a space. The next unit begins with 101 101 and is followed by 01111 01111 , which is 20+21+22+23=15 2^0+2^1+2^2+2^3=15 more than A A , so it represents P P . By analogy, the final translation is A  PIG A\;PIG .

Note:

For Rule 1 1 : the 26 26 uppercase letters are arranged in alphabetical order, starting from A=10100000 A=10100000 . Each subsequent letter’s binary code has a value exactly 1 1 greater than the previous letter’s binary code (remember to carry in base 2 2 ).

This problem is prone to misunderstandings. Please read the statement carefully, clarify the logical relationships, and pay attention to details.

Translated by ChatGPT 5