TSOC '15 Contest 1 #4 - Restaurant Of Secrets

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 64M

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

Now that BMP and MSA have arrived on the 8th floor, they find themselves in a famous five star restaurant where famous chef Mr. Benum keeps all of his fancy recipes. Legend has it that somewhere in the depths of the restaurant, Mr. Benum holds a list of key ingredients to the fabled cheesecake recipe. Of course, BMP and MSA want to get their hands on that blessed list, but it's not that simple.

The restaurant is a grid and its layout is quite tricky, BMP has decided that he will be the one looking for the list. However, he needs your help! BMP, wanting a challenge and having very limited time T, has decided to limit his movement to diagonals only (meaning, he cannot walk forwards, backwards, left or right). For example, if he is at (2,2), he can move to (3,3) but not (2,3). One diagonal movement takes 1 minute. He needs to get the list as soon as possible without Mr. Benum catching him. MSA knows the exact location of the list (X_L, Y_L), and BMP's starting position (X_S, Y_S). All that is left to do is to figure out the minimum amount of steps it takes to get from (X_S,Y_S) to (X_L,Y_L).

The restaurant size will always be 17 \times 17.

X_S and Y_S represent the X and Y coordinates of BMP, while X_L and Y_L represent the X and Y coordinate of the list.

Note that X_S and X_L (0 \le X \le 16) and Y_S and Y_L (0 \le Y \le 16).

Input Specification

The first line contains a single integer T.

Second line consists of two integers X_S and X_S separated by a single space, the coordinates of BMP.

And the third line consists of two integers X_L and Y_L, the coordinates of the list.

Output Specification

The minimum amount of steps it takes to get from (X_S, Y_S) to (X_L, Y_L). If BMP cannot make it to (X_L, Y_L) at all, output Cannot physically get there. If BMP cannot get to there within the time limit, output Cannot get there on time.

Sample Input

1 1
2 2

Sample Output

It takes 1 minute(s) to get to (2, 2).

Explanation for Sample Input

BMP starts his journey at coordinate (1, 1). He can diagonally move to (2, 2). The minimum amount of steps required for this case is 1.


  • 4
    kobortor  commented on Feb. 26, 2015, 9:08 p.m.

    If the range is 0 <= X, Y <= 16 then wouldn't the restaurant be 17x17?

    • 3
      BMP  commented on April 30, 2015, 3:15 p.m.

      After approximately 28 years, the problem statement has been fixed.

      • 3
        bobhob314  commented on April 30, 2015, 4:55 p.m.

        Congratulations! You just won the Thornhill's Most Responsible Contest Setter award!

        (The sad part is that that was not sarcasm.)

        • 0
          kobortor  commented on April 30, 2015, 7:10 p.m.

          wow that was really sad.