QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 64 MB Puntuación total: 50

#13583. 字幕

Estadísticas

为了理解外语电影中的对白,屏幕底部通常会显示翻译后的文字,俗称字幕。在数字世界中,字幕通常以 .SRT 文件的形式存储,该文件由以下格式的块组成:

[Ordinal number of the block]
[Beginning time of the subtitles --> Ending time of the subtitles]
[Subtitle text in one or more lines]

这些块之间由一个空行隔开。时间格式为 HH:MM:SS,TTT(注意冒号和逗号),表示 小时:分钟:秒,毫秒。一秒包含 1000 毫秒。以下是一个 .SRT 文件的示例:

1
00:00:01,600 --> 00:00:04,200
Good day!

2
00:00:05,900 --> 00:00:07,999
Good day to you too!
Here you go!

3
00:00:10,000 --> 00:00:14,000
May I please have ten garlic sausages?

有时字幕与对应的电影并不同步,例如会提前或滞后两秒出现。因此,我们希望将对应的 .SRT 文件(或该文件的一部分)中的所有时间向前或向后移动指定的(毫)秒数。请编写一个程序来实现这一功能。

输入格式

输入数据最多包含 30 行,代表某个 .SRT 文件的一部分。

第一行以序号为 $X$ 的块开始,随后是序号为 $X + 1, X + 2, \dots, X + K$ 的块,格式如题目描述中所述。

块与块之间用单个空行隔开。块内的字幕文本包含一行或多行非空行,其中包含英文字母和标点符号 ',.?!

最后一个块之后的下一行仅包含一个 # 字符,表示所观察的文件部分的结束,该字符不会在其他地方出现。

接下来的一行(最后一行)包含一个以毫秒为单位的时间 $T$($-10\,000 \le T \le 10\,000$),需要将其加到所有字幕块的时间中。

输出格式

输出输入数据中给出的 .SRT 文件部分,其中时间戳(每个块的开始和结束时间)应增加 $T$ 毫秒。测试样例将保证所需的时间戳不会为负数。

样例

输入 1

8
00:00:01,600 --> 00:00:04,200
We thought you was...

9
00:00:05,900 --> 00:00:07,999
a toad.
#
300

输出 1

8
00:00:01,900 --> 00:00:04,500
We thought you was...

9
00:00:06,200 --> 00:00:08,299
a toad.
#

输入 2

624
00:43:30,566 --> 00:43:32,108
Howdy do, ladies?

625
00:43:32,276 --> 00:43:33,943
Name of Pete.

626
00:43:47,124 --> 00:43:48,082
Ain't you gonna
introduce us, Pete?
#
-500

输出 2

624
00:43:30,066 --> 00:43:31,608
Howdy do, ladies?

625
00:43:31,776 --> 00:43:33,443
Name of Pete.

626
00:43:46,624 --> 00:43:47,582
Ain't you gonna
introduce us, Pete?
#

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.