#abc278b. B - Misjudge the Time

B - Misjudge the Time

Score : 200200 points

问题描述

Takahashi 买了一个台式钟表。
该钟表以如图1所示的方式显示时间,格式为AB\mathrm{AB}:CD\mathrm{CD},采用24小时制。例如,图2中的钟表显示的时间为7:58。

时间格式正式描述如下:

假设当前时间为24小时制下的hhmm分。在24小时制中,小时用0到23(含)之间的整数表示,分钟用0到59(含)之间的整数表示。

AAhh的十位数字,BBhh的个位数字,CCmm的十位数字,DDmm的个位数字。(此处,若hh只有一个数字,则视为其前面有一个零;mm同理。)

则钟表上显示的数字为:左上角为AA,左下角为BB,右上角为CC,右下角为DD

Takahashi 将满足以下条件的时间定义为混淆时间

  • 将钟表上的右上角和左下角的数字交换后,仍能读出一个有效的24小时制时间。

例如,图3中的钟表显示的时间为20:13。将其右上角和左下角的数字交换后,显示为21:03。因此,20:13是一个混淆时间。

现在钟表显示的时间为HH:MM
请找出下一个(包括当前时间)混淆时间,并以24小时制表示。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

Takahashi bought a table clock.
The clock shows the time as shown in Figure 1 at AB\mathrm{AB}:CD\mathrm{CD} in the 2424-hour system.
For example, the clock in Figure 2 shows 7:58.

The format of the time is formally described as follows.
Suppose that the current time is mm minutes past hh in the 2424-hour system. Here, the 2424-hour system represents the hour by an integer between 00 and 2323 (inclusive), and the minute by an integer between 00 and 5959 (inclusive).
Let AA be the tens digit of hh, BB be the ones digit of hh, CC be the tens digit of mm, and DD be the ones digit of mm. (Here, if hh has only one digit, we consider that it has a leading zero; the same applies to mm.)
Then, the clock shows AA in its top-left, BB in its bottom-left, CC in its top-right, and DD in its bottom-right.

image

Takahashi has decided to call a time a confusing time if it satisfies the following condition:

  • after swapping the top-right and bottom-left digits on the clock, it still reads a valid time in the 2424-hour system.

For example, the clock in Figure 3 shows 20:13. After swapping its top-right and bottom-left digits, it reads 21:03. Thus, 20:13 is a confusing time.

The clock now shows HH:MM.
Find the next confusing time (including now) in the 2424-hour system.

Constraints

  • 0H230 \leq H \leq 23
  • 0M590 \leq M \leq 59
  • HH and MM are integers.

Input

The input is given from Standard Input in the following format:

HH MM

Output

Let hh:mm be the answer, where hh and mm must satisfy 0h230 \leq h \leq 23 and 0m590 \leq m \leq 59.

Print hh and mm in the following format:

hh mm

Your answer is considered correct even if hh contains a leading zero to represent it as a 22-digit integer; the same applies to mm.

Sample Input 1

1 23

Sample Output 1

1 23

1:23 is a confusing time because, after swapping its top-right and bottom-left digits on the clock, it reads 2:13.
Thus, the answer is 1:23.
Your answer is considered correct even if you print 01 23 with a leading zero.

Sample Input 2

19 57

Sample Output 2

20 0

The next confusing time after 19:57 is 20:00.

Sample Input 3

20 40

Sample Output 3

21 0

Note that 24:00 is an invalid notation in the 2424-hour system.

update @ 2024/3/10 11:41:53