#C14695. Time Conversion and Manipulation

    ID: 44372 Type: Default 1000ms 256MiB

Time Conversion and Manipulation

Time Conversion and Manipulation

This problem requires you to implement a time converter that performs several operations related to time conversions and calculations. You need to support the following functions:

  • Convert hours to minutes: Given an integer \(h\), compute the total minutes using the formula \(minutes = h \times 60\).
  • Convert minutes to seconds: Given an integer \(m\), compute the total seconds using the formula \(seconds = m \times 60\).
  • Add two times: Given two times in the format "HH:MM:SS", return their sum in the same format. Note that the result can have an hour value that is 24 or more.
  • Validate a time string: Check if a string is a valid time in the format "HH:MM:SS", where \(0 \leq HH < 24\), \(0 \leq MM < 60\), and \(0 \leq SS < 60\).

The input will consist of a number of queries, each asking you to perform one of the operations above. Process each query accordingly and output the result on a new line.

inputFormat

The first line of the input contains an integer \(Q\) denoting the number of queries. Each of the following \(Q\) lines represents a query in one of the following formats:

  • H2M hours: Convert the provided hours to minutes.
  • M2S minutes: Convert the provided minutes to seconds.
  • ADD time1 time2: Add two times provided in the format "HH:MM:SS".
  • VALID time: Check if the provided time string in the format "HH:MM:SS" is valid.

outputFormat

For each query, output the result on a new line. For conversion operations (H2M and M2S) and addition (ADD), print the resulting integer or time string. For the validation query (VALID), print True if the time is valid and False otherwise.

## sample
5
H2M 1
M2S 15
ADD 01:45:30 02:30:45
VALID 23:59:59
VALID 24:00:00
60

900 04:16:15 True False

</p>