#P7374. Subtitle Timing Adjustment
Subtitle Timing Adjustment
Subtitle Timing Adjustment
You are given a subtitle file in the SRT format. The file consists of several subtitle blocks. Each block contains:
- The first line: the subtitle index number.
- The second line: the subtitle start time and end time in the format HH:MM:SS,SSS --> HH:MM:SS,SSS.
- One or more lines containing the subtitle text.
Times are provided in the format \(HH:MM:SS,SSS\), where \(HH\) is hours, \(MM\) is minutes, \(SS\) is seconds, and \(SSS\) is milliseconds. (Note that \(1\) second = \(1000\) milliseconds.)
Sometimes, a time discrepancy occurs during playback. To resolve this, you are required to adjust all timestamps by a given offset (in milliseconds). The offset can be positive (to speed up the subtitle) or negative (to delay it). When an adjusted time becomes negative, clamp it to \(00:00:00,000\).
inputFormat
The input consists of:
- An integer \(T\) on the first line representing the offset in milliseconds.
- The remaining lines represent the SRT file content. Each subtitle block is separated by an empty line. Each block is formatted as follows:
--> ...
Time is given in the format \(HH:MM:SS,SSS\).
outputFormat
Output the adjusted SRT file with the same structure as the input subtitles. Each timestamp in every block (both start and end) should be adjusted by the given offset. If an adjusted time is less than zero, it should be output as \(00:00:00,000\).
sample
1000
1
00:00:01,600 --> 00:00:04,200
Good day!
1
00:00:02,600 --> 00:00:05,200
Good day!
</p>