<PREV Problem:
NEXT>
Solved by 95 users: ...
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 

Chess end-game

Time limit = 3 seconds

Chess. We have free figures on the board. White: King, Queen. Black: King. White King is on c3 and should not move.

Black King is trying to survive as long as possible. Given White Queen and Black King positions you should find minimal number of moves until checkmate.

Input In the first line the posision of White Queen is given. In the second — the position of Black King. The situation in input is correct, i.e. all figures have different positions and and whites could not kill Black King next move.

Input#1
f2 
c1
Output#1
1
Input#2
f2 
a1
Output#2
1
Input#3
f4
a1
Output#3
2
Input#4
h3
a5
Output#4
6

Author:
folklor
6 September 2003

<PREV | Problem set | Search related messages | NEXT>


© acm.mipt DevGroup
The page was generated in 200ms

SW soft NIX
ID = 54.80.60.91