AtCoder Beginner Contest 184
C
Super Ryuma
AtCoder
⌀ 782
原题
← BD →
翻译中…

Problem Statement

翻译中…

There is an infinite two-dimensional grid, and we have a piece called Super Ryuma at square $(r_1, c_1)$. (Ryu means dragon and Ma means horse.) In one move, the piece can go to one of the squares shown below:

翻译中…

image

翻译中…

More formally, when Super Ryuma is at square $(a, b)$, it can go to square $(c, d)$ such that at least one of the following holds:

翻译中…
  • $a + b = c + d$
  • $a - b = c - d$
  • $|a - c| + |b - d| \le 3$
翻译中…

Find the minimum number of moves needed for the piece to reach $(r_2, c_2)$ from $(r_1, c_1)$.

翻译中…

Constraints

翻译中…
  • All values in input are integers.
  • $1 \le r_1, c_1, r_2, c_2 \le 10^9$
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

r_1 c_1
r_2 c_2

翻译中…

Output

翻译中…

Print the minimum number of moves needed for Super Ryuma to reach $(r_2, c_2)$ from $(r_1, c_1)$.

翻译中…

样例

Input #1
1 1
5 6
Output #1
2
We need two moves - for example, $(1, 1) \rightarrow (5, 5) \rightarrow (5, 6)$.
Input #2
1 1
1 200001
Output #2
2
We need two moves - for example, $(1, 1) \rightarrow (100001, 100001) \rightarrow (1, 200001)$.
Input #3
2 3
998244353 998244853
Output #3
3
We need three moves - for example, $(2, 3) \rightarrow (3, 3) \rightarrow (-247, 253) \rightarrow (998244353, 998244853)$.
Input #4
1 1
1 1
Output #4
0
题目信息
题号
abc184_c
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。