1006 - Ciphering Programs 1006 - Cifrando programas 1006 - Ciphering Programs

Statistics Sub: 1848 | AC: 541 | AC%: 29,27 | Score: 0,41
Created by 2010 Copa Pascal UCI
Added by ejaltuna (2011-10-13)
Limits
Total Time: 2000 MS |Memory: 62 MB | Output: 64 MB | Size: 4 KB
Enabled languages
Available in

Description

Enrique and Tomás are two good friends whose greatest entertainment is programming. As all good programmers, they challenge each other frequently, the challenges consisting mostly in solving online judge problems in as little time as possible. Enrique has observed that one of the motives that competition between them has become more even is the sharing of solutions between the two. This allows each programmer to know the tricks of the other. Enrique has decided to hide his solutions from Tomás and everyone else, but he has an inconvenience to guarantee it: He shares a workstation with Tomás. Wanting to avoid accidental access to his code he decides to encrypt everything in his programs. In order to do so he implements the following algorithm: Change every letter in the code for its successor in the English alphabet (respecting its case). If the letter in question is z, then its successor is assumed to be a. Then the algorithm rewrites each line as described as follows: first, the symbol in the centre of the text is written (if characters goes from positions 1 to n, then the first character in being written is the character in position (1+n)/2). Following the same strategy, the algorithm encodes the left half of the string, then the right and last half. Thus, the Pascal program:
program p1000(Input,Output);
var
    a,b:Integer;
begin
    Readln(a,b);
    Writeln(a+b);
end.
will be:
(npqsshb1 q000PqJouv,vuvq)u;
bws
:    ,bcfoJufhs;
hcfjo
e    fSbbom(c,);
f    sXjubom(c+);
ofe.
Enrique took a while programming the encoder, and now wants to ask you to help him revert the encryptions.
;jsessionid=E13C4A19561BD1E288E1B0DBD2AB9F0D
Enrique y Tomás son dos buenos amigos cuyo mayor entretenimiento es la programación. Como todos los buenos programadores, se desafían con frecuencia, los retos consisten principalmente en la resolución de problemas en los jueces línea en el menor tiempo posible. Enrique ha observado que uno de los motivos por lo que la competencia entre ellos se ha hecho más pareja es el intercambio de soluciones entre los dos. Esto permite a cada programador conocer los trucos del otro. Enrique ha decidido ocultar sus soluciones de Tomás y todos los demás, pero tiene un inconveniente para garantizarlo: Él comparte una estación de trabajo con Tomás. Queriendo evitar el acceso accidental a su código decide cifrar todo en sus programas. Con el fin de hacer esta tarea implementa el algoritmo siguiente: Cambia cada letra en el código por su sucesora en el alfabeto Inglés (respetando si son mayúsculas o minúsculas). Si la letra en cuestión es la z, entonces su sucesora es una a. Luego el algoritmo vuelve a escribir cada línea como se describe a continuación: primero, el símbolo en el centro del texto es escrito (si los caracteres van de las posiciones 1 a n, entonces el primer carácter que se escribe es el carácter en la posición (1 + n) / 2). Siguiendo la misma estrategia, el algoritmo codifica la mitad izquierda de la cadena, a continuación la derecha y última mitad. De este modo, el programa en Pascal:

program p1000(Input,Output);
var
    a,b:Integer;
begin
    Readln(a,b);
    Writeln(a+b);
end.
será:
(npqsshb1 q000PqJouv,vuvq)u;
bws
:    ,bcfoJufhs;
hcfjo
e    fSbbom(c,);
f    sXjubom(c+);
ofe.
A Enrique le tomó un rato programar el codificador, y ahora quiere pedirle a usted que le ayude a revertir las encriptaciones.
Enrique and Tomás are two good friends whose greatest entertainment is programming. As all good programmers, they challenge each other frequently, the challenges consisting mostly in solving online judge problems in as little time as possible. Enrique has observed that one of the motives that competition between them has become more even is the sharing of solutions between the two. This allows each programmer to know the tricks of the other. Enrique has decided to hide his solutions from Tomás and everyone else, but he has an inconvenience to guarantee it: He shares a workstation with Tomás. Wanting to avoid accidental access to his code he decides to encrypt everything in his programs. In order to do so he implements the following algorithm: Change every letter in the code for its successor in the English alphabet (respecting its case). If the letter in question is z, then its successor is assumed to be a. Then the algorithm rewrites each line as described as follows: first, the symbol in the centre of the text is written (if characters goes from positions 1 to n, then the first character in being written is the character in position (1+n)/2). Following the same strategy, the algorithm encodes the left half of the string, then the right and last half. Thus, the Pascal program:
program p1000(Input,Output);
var
    a,b:Integer;
begin
    Readln(a,b);
    Writeln(a+b);
end.
will be:
(npqsshb1 q000PqJouv,vuvq)u;
bws
:    ,bcfoJufhs;
hcfjo
e    fSbbom(c,);
f    sXjubom(c+);
ofe.
Enrique took a while programming the encoder, and now wants to ask you to help him revert the encryptions.
;jsessionid=E13C4A19561BD1E288E1B0DBD2AB9F0D

Input specification

The input consists of one program, encoded as per the strategy suggested by Enrique.
No line in this program contains more than 20000 characters.
La entrada consiste en un programa, codificado según la estrategia sugerida por Enrique.
Ninguna línea en este programa contiene más de 20000 caracteres.
The input consists of one program, encoded as per the strategy suggested by Enrique.
No line in this program contains more than 20000 characters.

Output specification

The output consists of Enrique's program decoded. This result will be exactly the same to the program originally described.
La salida consiste en el programa de Enrique decodificado. Este resultado será exactamente el mismo que el programa descrito originalmente.
The input consists of one program, encoded as per the strategy suggested by Enrique.
No line in this program contains more than 20000 characters.

Sample input

(npqsshb1 q000PqJouv,vuvq)u;
bws
:    ,bcfoJufhs;
hcfjo
e    fSbbom(c,);
f    sXjubom(c+);
ofe.

Sample output

program p1000(Input,Output);
var
    a,b:Integer;
begin
    Readln(a,b);
    Writeln(a+b);
end.

Hint(s)

http://coj.uci.cu/24h/
http://coj.uci.cu/24h/
http://coj.uci.cu/24h/

Recommendation

We have carefully selected several similar problems: 3376 | 2769 | 1873 | 2441 | 2534 | 2141