153. Parity Checker

Codeforces
IDCF10269153
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Though digital communications are highly accurate, errors can occur from time to time. To deal with such communications errors, methods to detect and fix errors have been invented. One very common and simple method for this is known as a parity bit. When a message is being sent digitally in the form of bytes of 8 bits, a ninth parity bit can be added that is either 1 if the message has an even number of 1s(in binary), or 0 if the message has an odd number of 1s. While this method clearly will only work if there are an odd number of errors, it is a useful heuristic for detecting many errors without the need for more computation intensive methods. Your task for this problem is to write a program to determine if a nine bit sequence of binary is valid according to a parity check. The first bit on the left represents the parity bit, and the following 8 bits correspond to the one byte message that is to evaluated for parity. Exactly 9 consecutive binary bits will be provided as input in the form of a one-line string with no spaces. The first bit on the left represents the even-parity bit, and the next eight bits represent the message being communicated. Output either "NO ERROR" if the parity check is valid or "TRANSMISSION ERROR" if the parity check fails. ## Input Exactly 9 consecutive binary bits will be provided as input in the form of a one-line string with no spaces. The first bit on the left represents the even-parity bit, and the next eight bits represent the message being communicated. ## Output Output either "NO ERROR" if the parity check is valid or "TRANSMISSION ERROR" if the parity check fails. [samples]
**Definitions** Let $ b \in \{0,1\}^9 $ be a binary string of length 9, where $ b = b_1 b_2 \dots b_9 $, with $ b_1 $ the parity bit and $ b_2, \dots, b_9 $ the 8-bit message. **Constraints** - Input is a single string of exactly 9 binary digits. **Objective** Let $ s = \sum_{i=2}^{9} b_i $ be the number of 1s in the message. The parity check is valid if: $$ b_1 = \begin{cases} 1 & \text{if } s \text{ is even} \\ 0 & \text{if } s \text{ is odd} \end{cases} $$ Output "NO ERROR" if valid, otherwise "TRANSMISSION ERROR".
API Response (JSON)
{
  "problem": {
    "name": "153. Parity Checker",
    "description": {
      "content": "Though digital communications are highly accurate, errors can occur from time to time. To deal with such communications errors, methods to detect and fix errors have been invented. One very common and",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10269153"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Though digital communications are highly accurate, errors can occur from time to time. To deal with such communications errors, methods to detect and fix errors have been invented. One very common and...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ b \\in \\{0,1\\}^9 $ be a binary string of length 9, where $ b = b_1 b_2 \\dots b_9 $, with $ b_1 $ the parity bit and $ b_2, \\dots, b_9 $ the 8-bit message.\n\n**Constraints**  \n- I...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments