-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC.py
More file actions
35 lines (30 loc) · 725 Bytes
/
C.py
File metadata and controls
35 lines (30 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
r1, c1 = map(int, input().split())
r2, c2 = map(int, input().split())
#同じ
if r1==r2 and c1==c2:
print(0)
exit()
#斜め
elif c1==r1-r2+c2 or c1==-(r1-r2)+c2:
print(1)
exit()
#3つ以内
elif abs(r1-r2)+abs(c1-c2) <= 3:
print(1)
exit()
#6つ以内
elif abs(r1-r2)+abs(c1-c2) <= 6:
print(2)
exit()
#斜め移動x2
if (r1+c1)%2 == (r2+c2)%2:
print(2)
exit()
else:
if (c1+1)==r1-r2+c2 or (c1+2)==(r1-1)-r2+c2 or c1==(r1+1)-r2+c2 or (c1-1)==(r1+2)-r2+c2 or (c1+1)==-(r1-r2)+c2 or (c1-1)==-(r1-r2)+c2 or (c1-2)==-(r1-1-r2)+c2 or (c1+1)==-(r1+2-r2)+c2:
print(2)
exit()
#斜め移動x2でいけないところ
else:
print(3)
exit()