## DMOPC '14 Contest 1 P4 - Perfect Timing

View as PDF

Points: 10 (partial)
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Being the friendly student you are, you decide to wait for Mr. Sidhu, your math teacher, in front of the Main Office as he delivers his attendance sheets. Since he is anxious to leave for home, he takes the shortest path possible, and walks at a speed of one metre per second.

The first line of input will consist of the coordinate for Mr. Sidhu's starting point while the following line will represent the coordinate of the Main Office. The coordinates satisfy A colleague texts you exactly when Mr. Sidhu leaves the math science office and so you wish to calculate exactly how much time it will take him to arrive as to make the encounter seem like a "sheer coincidence".

Note that Mr. Sidhu can only walk horizontally and vertically — not diagonally.

Unfortunately, simply showing the number of seconds remaining just isn't that user-friendly, and so you decide to display Mr. Sidhu's Estimated Time of Arrival.

The format used will be as follows: YYYY:MM:DD:HH:MM:SS (years, months, days, hours – use 24 hour time, minutes, seconds). Make sure to match the format exactly (with leading zeroes, if necessary). Take into account any leap years that may occur.

Also, for your program to accommodate for the multiverse theory, the years of both the starting time and of the arrival time will be between 1970 and 5000.

#### Sample Input

0 0
2 2
2014:10:14:15:15:58

#### Sample Output

2014:10:14:15:16:02

#### Explanation for Sample Output

(0, 0) (0, 1) (0, 2)
(1, 0) (1, 1) (1, 2)
(2, 0) (2, 1) (2, 2)

Mr. Sidhu starts at 0, 0 and makes his way to 2, 2. Since he can walk only horizontally and vertically, he walks a total of 4 meters. At his speed of 1 m/s, it will take him 4 seconds.

• commented on Feb. 27, 2016, 11:58 a.m. edit 2

My program keeps throwing a java.lang.Error, although there shouldn’t be anything in my code which would cause this.

Is there anything I’m doing wrong??

EDIT: when I resubmit with Java 7 instead of 8 the exception isn’t thrown anymore…

• commented on Dec. 3, 2014, 6:31 p.m.

I'm getting a "Number format exception" when I submit java. Am I not allowed to use this statement in the println?

(s > 9 ? s : "0" + s)

• commented on Dec. 3, 2014, 6:42 p.m.

There are multiple numbers on the same line of input.

• commented on Dec. 3, 2014, 7:03 p.m.

Thanks

• commented on Nov. 11, 2014, 4:03 p.m.

Must one take into account leap years??

• commented on Nov. 11, 2014, 7:35 p.m.