eolymp
bolt
Try our new interface for solving problems
Məsələlər

Arne Saknussemm

Arne Saknussemm

Following the account of Jules Verne, a scrambled message written by the middle age alchemist Arne Saknussemm, and deciphered by professor Lidenbrock, started the incredible travel to the center of the Earth. The scrambling procedure used by Arne is alike the procedure given below. ' 1. Take a non empty message M that contains letters from the English alphabet, digits, commas, dots, quotes (i.e. ), spaces and line breaks, and whose last character is different than space. For example, consider the following message whose translation reads "In Sneffels's crater descend brave traveler, and touch the center of the Earth". \begin{verbatim} In Sneffels craterem descende audasviator, et terrestre centrum attinges.\end{verbatim}2. Choose an integral number \textit{0} and add trailing spaces to \textit{M} such that the length of the resulting message, say \textit{M'}, is the least multiple of \textit{K}. For \textit{K=19} and the message above, where \textit{length(M)=74} (including the \textit{8} spaces and the line break that \textit{M} contains), two trailing spaces are added yielding the message \textit{M'} with \textit{length(M')=76}. _ \ 3. Replace all the spaces from \textit{M'} by the character (underscore) ; replace all the line breaks from \textit{M'} by (backslash), and then reverse the message. In our case: \begin{verbatim} __.segnitta_murtnec_ertserret_te_,rotaiv\sadua_ednecsed_meretarc_sleffenS_nI\end{verbatim}4. Write the message that results from step 3 in a table with \textit{length(M')/K} rows and \textit{K} columns. The writing is column wise. For the given example, the message is written in a table with \textit{76/19=4} rows and \textit{19} columns as follows: 5. The strings of characters that correspond to the rows of the table are the \textit{fragments} of the scrambled message. The \textit{4} fragments of Arne's message given in step 1 are: Write a program that deciphers non empty messages scrambled as described. The length of a message, before scrambling, is at most \textit{1000} characters, including spaces and line breaks. \InputFile The program input is from a text file where each data set corresponds to a scrambled message. A data set starts with an integer n, that shows the number of fragments of the scrambled message, and continues with n strings of characters that designate the fragments, in the order they appear in the table from step 4 of the scrambling procedure. Input data are separated by white-spaces and terminate with an end of file. \OutputFile The deciphered message must be printed on the standard output, from the beginning of a line and must be followed by an empty line as shown in the input/output sample below.
Zaman məhdudiyyəti 1 saniyə
Yaddaşı istafadə məhdudiyyəti 64 MiB
Giriş verilənləri #1
4  _etmneet_t\udsmt_fS
   _gtuerr_,asaneeasf_
   .narctrtria_edrrlen
   si_t_seeovdec_ecenI
11 e n r e V _ s e l u J
Çıxış verilənləri #1
In Sneffels craterem descende audas
viator, et terrestre centrum attinges.

Jules Verne
Mənbə Southeastern Europe 2007