HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Contests > CEN303_2016Questions > problem:


HW051. 51019 - Finding the hidden message

CEN303_2016Questions

Start: Oct.28.2016 at 05:00:00 PM
Finish: Nov.01.2016 at 05:00:00 AM
The contest is finished!
• Contest scoreboard

Guest
• Review clarifications (7)

Contest problems

• HW011. 51008 - Sum of Regional M...
• HW012. 51009 - Sum of the nth row
• HW021. 51011 - Decoding the Path
• HW022. 51012 - Palindrome-k
• HW023. 50741 - DNA Distance
• HW031. 51015 - Student Scholarships
• HW032. 51014 - Nine Men's Morris g...
• HW033. 50925 - Optimizing Elevator...
• HW051. 51019 - Finding the hid...
• HW052. 51020 - Number of nodes r...
• HW061. 50448 - Paint Buckets
• HW062. 51021 - Number of Nodes
• HW071. 51042 - The most frequent ...
• HW072. 51043 - Genome Sequencing
• HW081. 51044 - Number of Trees
• HW082. 50699 - Fighting Vampires
• HW083. 50671 - Phalanx

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