問題一覧 > 通常問題

No.1412 Super Ryuo

レベル : / AI推定難易度 : 400 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 201
作問者 : evima / テスター : 37zigen iaNTU
お気に入りにしたユーザー ProblemId : 5794 / 自分の提出
問題文最終更新日: 2021-03-05 09:34:04
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
1時間コンテスト02 (順位表) の他の問題:

Problem Statement

There is a board extending infinitely in the vertical and horizontal directions, as shown in the figure below.

A piece called "Super Ryuo" is on square $(A, B)$ of this board.
In one move, this piece can perform one of the following movements.

  • Move like a "Rook".
    Formally, if the square before the move is $(X, Y)$, choose any integer $Z$ and move to $(Z, Y)$ or $(X, Z)$.
  • Move by $1$ square vertically or horizontally, up to $3$ times.
    Formally, if the square before the move is $(X, Y)$, choose any pair of integers $Z, W$ such that $|X - Z| + |Y - W| \leq 3$ and move to $(Z, W)$.
The possible destinations are illustrated below (the piece can move in one move to the squares painted in colors other than white).

Find the minimum number of moves required for this piece to reach square $(C, D)$.

Input

$A\ B\ C\ D$

  • $-10^9 \leq A, B, C, D \leq 10^9$
  • $(A, B) \neq (C, D)$
  • $A, B, C, D$ are integers

Output

Print the answer as an integer, followed by a newline.

Sample

Sample 1
Input
1 1 2 3
Output
1

From $(1, 1)$, you can reach $(2, 3)$ in $1$ move by moving by $1$ square vertically or horizontally $3$ times.

Sample 2
Input
1 1 2 -1000000000
Output
2

The destination cannot be reached in $1$ move, but it can be reached in $2$ moves, for example, by performing the movement described in Sample 1 and then moving like a Rook.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。