All submissions for this problem are available.
Consider a K×K square made of K2 unit squares. The center of the lowermost, leftmost unit square has coordinates (0, 0) and the center of the rightmost, uppermost unit square has coordinates ((K-1), (K-1)). Consider a robot that can move only in a straight line and cannot change its direction once it starts moving. If the robot starts from the center (p,q) of a unit square to retrieve an object from the center (r,s) of another unit square, what is the number of unit squares it has to pass through? Note that touching any boundary point on a unit square also counts as passing through that unit square.
The first line contains the number of test cases N (0 < N ≤ 3).
For each test case, the first line contains K (1 < K ≤ 10000), the dimension of the grid. The second line contains the x and y coordinates (in that order, separated by one or more spaces) of the starting point of the robot. The third line contains the x and y coordinates (in that order, separated by one or more spaces) of the destination point of the robot.
For each test case, in the first line, print the case number, followed by a colon, followed by a single space, followed by a single integer indicating estimated minimum travel time.
3 8 0 7 3 0 8 1 0 7 1 8 3 3 7 7
Case 1: 12 Case 2: 8 Case 3: 13
|Tags||admin3, kgp14ros, maths, medium|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.