Changyong's Clock
Time limit1sMemory limit512 MB
Track a clock's time on a 24-hour dial, turning it forward or backward by c seconds and answering queries for the current time.
- Level
Easy2 of 10
- Topics
- Simulation, Math, Implementation
- Solved
- No attempts yet
Problem
Changyong bought a limited summer edition watch. He took the battery out, so the watch does not advance on its own. The hands move only as far as Changyong turns them.
Changyong turns the watch forward and backward. You are given the time the watch shows at the start and queries. Each query begins with .
- If is 1, an integer follows. Turn the watch forward by seconds.
- If is 2, an integer follows. Turn the watch backward by seconds.
- If is 3, print the time the watch shows at that moment.
The watch runs on a 24-hour dial. Turning it forward by one second from 23:59:59 gives 0:0:0, and turning it backward by one second from 0:0:0 gives 23:59:59.
and .
Input
The first line contains the starting time as . (, , )
The second line contains the number of queries . ()
Each of the next lines contains one query. A query with equal to 1 or 2 gives and separated by a space, and a query with equal to 3 gives only .
Output
For every query with equal to 3, print the time the watch shows at that moment as on its own line. Separate the three values with a single space and do not pad them with zeros. At least one query has equal to 3.