Bored Jungyu
Time limit1sMemory limit128 MB
Given XOR values of a lowercase/period/space plaintext with a digit key, decide for each position whether the original was a letter or a period/space.
- Level
Medium6 of 10
- Topics
- Bit manipulation, Brute force, String
- Solved
- No attempts yet
Problem
Haebin received an encrypted message from Jungyu. Jungyu used a One-Time Pad (OTP) this time. When OTP is used correctly, the entire original message cannot be recovered, but Jungyu left enough information for Haebin to at least locate spaces and periods.
Jungyu's plaintext uses only lowercase English letters, periods (.), and spaces (ASCII code 32). The key uses only the digit characters from '0' through '9'. Each character of the plaintext and the key is converted to its ASCII code, and the encrypted message is produced by XORing the codes at the same positions.
For example, using plaintext abc efg and key 0120123 encrypts the message as follows.
Given the encrypted message, determine for each position whether the original character was a lowercase letter or was a period or space.
Input
The first line contains an integer N, the length of the encrypted message. (1 <= N <= 1000)
The second line contains N space-separated integers forming the encrypted message. Each integer is written in decimal and is between 0 and 127, inclusive.
Output
For each position in the original message, print - if the character was a lowercase letter, and print . if it was a period or a space.
Print exactly N characters on one line.