P7374 [COCI 2018/2019 #5] Titlovi

Description

There is a `.SRT` file that consists of several subtitle blocks, which are loaded when watching a video. Each subtitle block has three parts: - Line 1: the subtitle index. - Line 2: subtitle start time --> subtitle end time. - The following several lines: subtitle text. Here is an example subtitle file: ```plain 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? ``` All times are given in the format `HH:MM:SS,TTT`, representing hours, minutes, seconds, and milliseconds. It is given that $1$ second $= 1000$ milliseconds. Sometimes there may be a time offset during playback, so when loading the subtitles, you need to shift all subtitle times forward / backward by a specific amount of time, and output the adjusted `.SRT` file.

Input Format

The input contains at most $100$ lines, representing the content of a `.SRT` file. For the first line of each subtitle block, the subtitle index is given. If the first block has index $X$, then the $i$-th block must have index $X + i - 1$. Each subtitle block is separated by one empty line. Subtitle text contains English letters, spaces, and characters such as `,.?!.`, etc. The line after the last line of the last subtitle block will contain a single character `#`, indicating the end of the subtitle section. The next line / the last line of the input contains an integer $T$, which is the time shift to apply. If $T \ge 0$, it means shifting the subtitle times backward by $T$ milliseconds. Otherwise, it means shifting the subtitle times forward by $-T$ milliseconds.

Output Format

Output the `.SRT` file after shifting the times.

Explanation/Hint

#### Constraints For $100\%$ of the testdata, $-10^4 \le T \le 10^4$. #### Notes **The score of this problem follows the original COCI settings, with a full score of $50$.** Note: After testing, the official input files may contain Windows-generated characters such as `\r`. Please pay attention to this during processing. **Translated from [COCI2018-2019](https://hsin.hr/coci/archive/2018_2019/) [CONTEST #5](https://hsin.hr/coci/archive/2018_2019/contest5_tasks.pdf) _T1 Titlovi_.** Translated by ChatGPT 5