#P2655. Epoch Time Overflow Problem

    ID: 15920 Type: Default 1000ms 256MiB

Epoch Time Overflow Problem

Epoch Time Overflow Problem

In the network era, opportunities and crises coexist. After the "Y2K" bug was solved, another bug known as the "2038 problem" has emerged for many C programs. This is because most C programs use the standard time library which stores time as a 32-bit (N = 32) signed integer. In this scheme, the time count starts at the epoch of 1970-01-01 00:00:00 (when the counter value is 0) and increments by one every second. The maximum value that can be stored is:

$$2^{N-1}-1$$

Once the counter exceeds this value, it will become negative and time computations will fail. For example, when N = 32, the maximum valid time is obtained by adding $$2^{31}-1 = 2147483647$$ seconds to the epoch time, resulting in 2038-01-19 03:14:07.

Your task is to generalize this scenario. Given an integer N representing the number of bits used for the time variable and a starting epoch time, compute the final valid time obtained by adding 2N-1 - 1 seconds to the given epoch.

Note: When including formulae, use LaTeX format as shown above.

inputFormat

The input consists of two lines:

  • The first line contains an integer N (the bit-length of the time variable).
  • The second line contains the epoch time in the format YYYY-MM-DD HH:MM:SS.

outputFormat

Output the final valid time (i.e. epoch time plus 2^(N-1)-1 seconds) in the format YYYY-MM-DD HH:MM:SS.

sample

32
1970-01-01 00:00:00
2038-01-19 03:14:07