#K79307. Reverse Shift Encoding

    ID: 35279 Type: Default 1000ms 256MiB

Reverse Shift Encoding

Reverse Shift Encoding

In this problem, you are required to implement a simple encoding and decoding scheme for messages. The encoding process involves two steps:

  1. Reverse the input string.
  2. Shift every character in the reversed string by an integer value (n) in the ASCII table ((n) can be positive, zero, or negative).

The decoding process reverses these operations:

  1. Shift every character in the encoded string by (-n) in the ASCII table.
  2. Reverse the resulting string to obtain the original message.

Your task is to implement these functions such that when a message is encoded and then decoded with the same shift value, the final output matches the original message exactly.

Be careful to correctly handle edge cases, such as empty strings, single-character strings, and shift values that are negative or very large.

inputFormat

The input consists of two lines. The first line contains an integer (n) representing the shift value. The second line contains the message string (s) which may include spaces and special characters. Note that the string can be empty.

outputFormat

Output the original message after encoding it and then decoding it using the given shift value.## sample

3
hello
hello