|
||||||||||
DateTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 328 Accepted Submission(s): 71 Problem Description Is it just another problem about year, month and day? No, today we have a more romantic meaning ¨C dating with a girl. iSea now has a date to be anxious to rush, unfortunately, the city's way is always so complicated, so time goes unconsciously and fast. In order to more quickly rushed to rendezvous, iSea has already drawn a topographic map of this city, he find that the city is composed of a number of equal squares, between the squares, there are some traffic lights controlling the traffic, a basic map example: iSea¡¯s map gives some more specific information about the city, the number of vertical grid N, the number of horizontal grid M, and the time the traffic lights change alternating. In order to simplify the problem, we assume that one day start at 0 hour, traffic lights first allow passengers traverse the intersection from left and right, but block up and down in the intersection, after a time Ti, the traffic lights block left and right to allow access up and down, the time is also the Ti, so the cycle goes. After simple calculation, iSea finds he may be late for this date, in order to reach the destination in time, he decides to make one exception, in an emergency he would pass through a intersection even if a red light was lighten, but not to loss of too many RP, he asks himself go across the red light at most once, then, can you help him, calculate when he could arrive in rendezvous at the earliest? Input There are several test cases in the input. Each test case begin with two integers N, M (1 < N, M ¡Ü 30), indicating the number of the vertical grid and the horizontal grid. Then N-1 lines follow, each line contains M-1 numbers Ti (0 < Ti ¡Ü 10), their meaning is in the description. The last line is the start time of iSea, in the form of HH:MM. The input terminates by end of file marker. Output For each test case, output the earliest time iSea can arrive, in the form of HH:MM, you may assume that all the things happen within the same day Sample Input
Sample Output
Author iSea @ WHU Source | ||||||||||
|