QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 512 MB مجموع النقاط: 50

#11429. 公交车

الإحصائيات

Malnar 先生决定去访问他尚未去过的少数几个城市之一:位于波兰西南部的弗罗茨瓦夫(Wrocław)。由于他很久没有乘坐巴士旅行了,他很怀念这种体验;然而,令他失望的是,他得知萨格勒布(Zagreb)和弗罗茨瓦夫之间没有直达的巴士线路。

最好的替代方案是在奥地利城市格拉茨(Graz)中转。Malnar 先生找到了时刻表,即一份在 Zagreb-Graz 和 Graz-Wroclaw 路线上的巴士线路列表。特定路线上的巴士每天运行,在出发时间的分钟开始时准时出发,并在到达时间的最后一分钟结束时准时到达。中转所需的时间可以忽略不计,即如果你在下一班巴士出发前到达目的地,就可以换乘(第一班巴士的到达时间必须严格早于第二班巴士的出发时间)。

确定从萨格勒布前往弗罗茨瓦夫所需的最短时间。

输入格式

第一行包含一个正整数 $n$ ($1 \le n \le 200$),表示巴士线路的数量。

在接下来的 $n$ 行中,按顺序给出由符号 "-" 连接的两个城市名称,第一个代表出发城市,第二个代表目的地城市,随后是格式为 h:mm--h:mm 的出发时间和到达时间,其中 h 表示小时,mm 表示分钟。注意,分钟总是显示为两位数字。如果分钟数是个位数,则会包含一个前导零。保证每次行程(不含中转)最多持续 24 小时。

输出格式

如果可以从萨格勒布前往弗罗茨瓦夫,请在第一行以 h:mm 格式(如上所述)打印旅行时间。

如果无法到达,请在第一行打印 "NEMOGUCE"(不含引号,克罗地亚语意为“不可能”)。

子任务

子任务 分值 数据范围
1 9 $n \le 3$
2 19 在 Zagreb-Graz 路线上的巴士线路恰好有一条
3 22 无额外限制

样例

样例输入 1

4
Zagreb-Graz 15:30--23:59
Graz-Wroclaw 10:42--19:15
Zagreb-Graz 14:13--20:19
Graz-Wroclaw 2:25--5:00

样例输出 1

13:31

样例输入 2

3
Zagreb-Graz 6:05--16:40
Zagreb-Graz 20:00--21:40
Zagreb-Graz 9:56--22:36

样例输出 2

NEMOGUCE

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.