Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

Romok007's blog

By Romok007, history, 3 years ago, In English

Hello everyone, I came across this beautiful problem Problem. However in order to solve this problem it assumes that the shortest distance between a king at point (x, y) and any arbitrary point (x', y') is given as max(|x' — x|, |y' — y|).

The above distance is Chebyshev Distance and it is true for Kings on a chessboard. Can someone help me with the proof or at least an intuition why the above formula is true. Thanks in advance :).

  • Vote: I like it
  • +1
  • Vote: I do not like it

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Among two Cordinates X and Y move diagonally until you cover up the smaller one and then straight path to the destination Eventually you are covering max(|x' — x|, |y' — y|.(Example Starting pt ->(0,0) and Destination pt -> (3,1) What you can do is take first step diagonally and you will reach to (1,1) then 2 steps vertically.