Hidden message X96443


Statement
 

pdf   zip

html

Josep and Maria often need to exchange information and do not want the rest of their office mates to know. For this they have agreed a simple cipher that hides the message into a square matrix of capital letters. You have to make a program that receives a matrix with a hidden message and writes the hidden message.


To retrieve the message you have to follow a (cyclic) traversal by diagonals of the matrix in ascending order (see figure) and take into account some additional parameters.

  • ℓ the number of characters you need to remove the matrix.
  • p the starting position of the first letter of the encoded message.
  • d the number of positions to be skipped (in the traversal in ascending diagonal order) to find the next letter of the hidden message.

We also know that the original message is composed of words containing only uppercase letters and that the white space separating two words has been rewritten, before hiding, with the combination XX.


Your program must use the following definition:

struct Coord {

  int x,y;

};

and also has to define, implement and use the function:

Coord nextD (const Coord& p, int n);

that, given the coordinates of a position in an square matrix n × n , computes the next position according to a traversal in ascending diagonal order. For example when n=8, the function when p=(7,7) has to return the coordinates (0,0), when p=(0,7), (7,1) and when p=(2,1), (1,2).

Input

The input consists of several lines containing information on arrays with hidden messages. The description of a matrix begins with a line of 5 integers, d, n, ℓ (d ℓ < n2) y f, c, (p =(f,c) with 0≤ f,c< n) determining the parameters. Followed by n lines describing the matrix M that hides the message by rows.

Output

For each matrix, the output is formed by the hidden message, written with words separated by a blank. You can assume that the combination XX never forms part of a word in the original message, that the combination XXX never occurs in a hidden message and that any message has at least one word.


Follow the format specified in the examples.


Public test cases
  • Input

    6 0 34 0 0
    ATNDNO
    NOXXCY
    HXXXXE
    YDXXTA
    ITESDP
    OMERYG
    
    4 0 12 2 2
    XMIX
    XRXE
    AXHL
    AXLO
    
    5 1 12 2 0
    ARELM
    CUAXR
    HLXMR
    LOARI
    PXAIA
    
    8 3 15 4 2
    PPPPPPID
    PPPPPPPP
    SAPPPPPP
    PGPPPPXP
    PPHDEPPP
    EPPPPXPP
    PPPPPMEP
    PPNPPPPS
    

    Output

    ANTHONY DID NOT COME YESTERDAY
    HELLO MARIA
    HELLO MARIA
    HIDDEN MESSAGE
    
  • Information
    Author
    Maria J. Serna i Maria J. Blesa
    Language
    English
    Translator
    Maria J. Serna
    Original language
    Catalan
    Other languages
    Catalan Spanish
    Official solutions
    Unknown. This problem is being checked.
    User solutions
    C++