COCI 2009/2010, Contest #6

Task DOSADAN

Mirko received a message from his friend Slavko. Slavko, being a world class cryptologist, likes to encrypt messages he sends to Mirko. This time, he decided to use One Time Pad encryption. OTP is impenetrable if used correctly, and Slavko knows this. He however, doesn't want Mirko to bang his head on an impossible task, so he sent a few hints along with his message.

Mirko knows that Slavkos original plaintext contained only small letters of the English alphabet ('a' - 'z'), full stop '.' and space ' ' (ASCII 3210). Also, he knows that Slavko used only digits '0' to '9' as his key. After much thought, he realized he can determine locations of all spaces and full stops in the plaintext. He now asked you to write a program that will do so automatically.

From his previous dealings with Slavko, Mirko knows how OTP encryption works. Let's look at a simple example. Suppose you want to encode the string "abc efg" using "0120123" as key.

abc efg
0120123
61 62 63 20 65 66 67
30 31 32 30 31 32 33
51 53 51 10 54 54 54
Start ASCII Hexadecimal Encrypted Message

First, you transform both the key and plaintext into hexadecimal numbers using ASCII encoding. Then you align them and perform the XOR operation on each pair. The resulting sequence is the encrypted message.

Input

The first line of input contains one integer N, (1 ≤ N ≤ 1000), the number of characters in the encrypted message.

The next line contains N integers, written in hexadecimal, larger than or equal to 010 and smaller than or equal to 12710, the encrypted message.

Output

The first and only line of output should contain N characters, each representing one character in the plaintext. If the ith character of plaintext is a letter, the ith character of output should be a dash '-', if not, you should output a full stop '.'.

Sample Tests

Input

7
51 53 51 10 54 54 54

Output

---.---

Input

7
53 53 51 54 54 51 10

Output

------.

All Submissions
Best Solutions


Point Value: 5
Time Limit: 1.00s
Memory Limit: 32M
Added: Jul 02, 2013

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

Comments (Search)

What's the XOR operation?
When I do :
print(61^30) in python 3 it gives me 35 instead of 51.

The 61,30, and 51 in the input are ALL hexadecimal numbers. If you want python to do the same, you will have to convert the inputs to the XOR(61 and 30) to decimal, and the output to hexadecimal. Try print(hex(0x61^0x30)) instead. The 0x prefix indicates a hexadecimal number.

I solved the problem, but the first version of my code strangely enough fails on 3 problems, while apparently still gives me the same output of the working one, even when tested with the problem's datasets.

I am at a loss here: any idea what's wrong with the first version of my code?