31.07.2015 Views

LITHUANIAN OLYMPIADS INFORMATICS

LITHUANIAN OLYMPIADS INFORMATICS

LITHUANIAN OLYMPIADS INFORMATICS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The message was hidden in the squaretable with contained different symbols(mostly letters). Square grid of the samesize with little holes in certain places wasused for decryption. For example, see picture190.1.The grid was put on the table and certainletters could be seen through the holes.The beginning of the encrypted messagewas obtained by reading those unhiddenletters from left to right and from the upperpart downwards. Then the grid wasturned by 180 degrees and the other letterscould be seen. After reading those lettersin the mentioned order, the end ofmessage was obtained. The whole messagewas decrypted like picture 190.2.The hidden message is there: GINKLAI YRA!After the message had been written to certain cells (according to the chosen grid),freely chosen letters and symbols were written into empty cells of the table and theencryption process was over.Task. Write a program to find the grid that should be used for encryption usinggiven the square table with symbols and the message. The input data are such that thesolution always exists. If several solutions are possible find any one of them.Input. The first line of the input file contains the message (not encrypted). Thelength of the message is from 2 to 100 symbols and it is necessarily divisible by 2.The second line contains the size N (1 ≤ N ≤ 50) of the grid (and of the letter table)used for encoding. The remaining N lines contain the letter table. Each line containsN symbols; there are no spaces between them.Only capital letters, punctuationmarks and space characters can be usedin the table and in the message. Neithermessage, nor any line of the table endswith space character.Output. The found grid should bewritten to the output file containing Nlines and each line containing N symbols.Holes should be marked with capitalO, and the remaining cells should bemarked with the capital X.G U D A S A SE M I E !N Y I A G O NA A A R B D KR N A A A K IŠ L V A ! M V! U S S O !GLPicture 190.1I N YAInputGINKLAI YRA!7GUDASASE MIE !NYIAGONAAARBDKRNAAAKIŠLVA!MV!USSO !K R APicture 190.2ExampleIResultOXXXXXXXXXXXXXXXOXXXOXXXXXXXXXXXXOXXOXOXXXXXXXXXX13!

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!