2682.Chess

Time Limit: 1s Memory Limit: 256MB

Two chess pieces, a rook and a knight, stand on a standard chessboard 8 \times 8 in size. The positions in which they are situated are known. It is guaranteed that none of them beats the other one.

Your task is to find the number of ways to place another knight on the board so that none of the three pieces on the board beat another one. A new piece can only be placed on an empty square.

Input Format(From the terminal/stdin)

The first input line contains the description of the rook's position on the board. This description is a line which is 2 in length. Its first symbol is a lower-case Latin letter from a to h, and its second symbol is a number from 1 to 8. The second line contains the description of the knight's position in a similar way. It is guaranteed that their positions do not coincide.

Output Format(To the terminal/stdout)

Print a single number which is the required number of ways.

Sample Input 1

Copy
a1
b2
  \n
  \n

Sample Output 1

Copy
44
  \n

Sample Input 2

Copy
a8
d4
  \n
  \n

Sample Output 2

Copy
38
  \n

Submit

请先 登录

© 2025 FAQs