HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Array and Matrices > problem:


51019 - Finding the hidden message

Guest
• Review clarifications (7)

Volume problems

• 50434 - Row Min Subtraction
• 50442 - Polynomial Addition
• 50869 - Birthday Celebration
• 50870 - ZScore normalization
• 50513 - Climbing Up the Stairs
• 50821 - Derivative of an array
• 50854 - Area of Triangle Revised
• 50520 - Filling a Matrix Randomly
• 51019 - Finding the hidden mes...
• 50497 - Falling Bricks - Revisited
• 51002 - The most successful classes
• 50847 - The first m trains to leave
• 50669 - Area of an Irregular Polygon
• 50860 - Number of Student Certificates
• 50444 - n digit kth number divisible...
• 50865 - Apartment Building Adminis...
• 50531 - File Decryption

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Question by Ibrahim Mesecan.

Finding the hidden message

Your friend needs some support in his exam. You will send him a message hidden in a matrix. Only you and your friend know the starting position. Then you will encode the message in the following way.

The matrix is a 2D integer array. Assume that the first byte is the least significant byte of the integer number. int num =(B4 B3 B2 B1). The first byte (B1) contains a hidden char, the next two bytes (B2 and B3) of every number is encoded in a way so that you can get the x (B2) and y (B3) coordinate of the next position in the array. You know that the message stops when B1 = (B2+B3).

Question: Write a program that reads a 2D matrix and prints the hidden message.

Input specification: You will be given three integers (n) in the beginning, and the starting coordinate (x, y) of the message. The following n lines will have n integers where 0 < n ≤ 100 and matrix values are integers less than 2e9. Note: array positions are integers between 1 and n.

Output specification: Show the hidden message.

Sample Input
5 2 4
786698 328276 197199 1982337 4544789
263506 5919586 4656938 66133 145576
2894514 263245 3213120 1927649 3492114
2237893 66371 5335242 132176 263433
5136373 131397 2193877 1787826 4921748
Sample Output
COMPUTER

Explanation: The matrix is 5 by 5, and you know that you will start from (2,4). The number (66371)10 is (10000001101000011) 2 where first byte is 67 = (01000011)2 which is the char 'C' in the ASCII table. The second byte is 3 (00000011)2 which is the x coordinate of the next char. The third byte is 1 = (00000001)2, the y coordinate of the next char. Thus, the second char is hidden in (3,1): (197199)10 is (110000001001001111) 2, and the hidden char is 79 = (001001111)2 which is the char 'O' in the ASCII table.

The char at (1,2) is 'R' and it points to (5,4) where the secret message ends because B1 = B2 + B3 (263433)10 is (100 00000101 00001001)2.



Для отправки решений необходимо выполнить вход.

www.contester.ru