Пожалуйста, подпишитесь на официальный канал Codeforces в Telegram по ссылке https://t.me/codeforces_official. ×

Блог пользователя Romok007

Автор Romok007, история, 3 года назад, По-английски

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 :).

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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.