CF722A.Broken Clock

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.

You are given a time in format HH:MM that is currently displayed on the broken clock. Your goal is to change minimum number of digits in order to make clocks display the correct time in the given format.

For example, if 00:99 is displayed, it is enough to replace the second 9 with 3 in order to get 00:39 that is a correct time in 24-hours format. However, to make 00:99 correct in 12-hours format, one has to change at least two digits. Additionally to the first change one can replace the second 0 with 1 and obtain 01:39.

你有一个坏掉的钟表。你知道它本应以 12 小时制或 24 小时制的 HH:MM 格式显示时间。在 12 小时制中,小时部分取值范围为 1 到 12;而在 24 小时制中,小时部分取值范围为 0 到 23。在这两种格式中,分钟部分均取值范围为 0 到 59。

你被给定一个当前在坏掉的钟表上显示的时间(格式为 HH:MM)。你的目标是修改最少数量的数字位,使得该钟表显示一个在指定格式下合法的时间。

例如,若显示的是 00:99,那么只需将第二个 9 替换为 3,即可得到 00:39,这是一个合法的 24 小时制时间。然而,若要使 00:99 成为一个合法的 12 小时制时间,则至少需要修改两位数字:除上述修改外,还可将第一个 0 替换为 1,从而得到 01:39。

输入格式

The first line of the input contains one integer 12 or 24, that denote 12-hours or 24-hours format respectively.

The second line contains the time in format HH:MM, that is currently displayed on the clock. First two characters stand for the hours, while next two show the minutes.

输入的第一行包含一个整数,为 12 或 24,分别表示 12 小时制或 24 小时制。

第二行包含以 HH:MM 格式显示的时间,即钟表当前显示的时间。前两个字符表示小时,后两个字符表示分钟。

输出格式

The only line of the output should contain the time in format HH:MM that is a correct time in the given format. It should differ from the original in as few positions as possible. If there are many optimal solutions you can print any of them.

输出仅应包含一行,格式为 HH:MM 的合法时间(符合给定格式)。该时间与原始输入在尽可能少的位置上不同。若存在多个最优解,输出任意一个即可。

输入输出样例

  • 输入#1

    24
    17:30

    输出#1

    17:30
  • 输入#2

    12
    17:30

    输出#2

    07:30
  • 输入#3

    24
    99:99

    输出#3

    09:09

输入解题思路,AI测评打分。不知道怎么写?

首页