KNMOVE - Knight Move
Daniel is a chess player. At his free time, he usually plays chess with his family or his friends. But, sometimes they have their own activities, so Daniel can't play chess. He spends his time to learn about knight's move. He has 1,000 x 1,000 chessboard, numbered from 1 to 1,000. He wants to move his knight from (a,b) to (1,1) with minimum movement. Help Daniel to solve it.
The input file consists of several lines.
The first line contains a single number t representing the number of question Daniel asked. [ 1<=t<=1,000 ]
The next t lines contains a and b representing knight's position on the chessboard. [ 1<= a,b <= 1,000 ]
The output file should contains t lines.
The i-th line should contain one number – the minimum number of knight's movement.
Yeah, accepted in first attempted.Last edit: 2020-07-03 11:11:32
@syamphanindra Did precomputation and still got TLE. Why is that? Language used is Java.
Done all the precomputation then why the fuck is TLE comming.
one go... got ac :) must precompute all and then perform test cases
@macbox do some precomputation
Getting TLE with bfs what technique should i use to optimize code ?