38B.md (1109B)
1 Source: https://codeforces.com/problemset/problem/38/B 2 3 B. Chess 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 stdin 16 17 output 18 19 stdout 20 21 Two chess pieces, a rook and a knight, stand on a standard chessboard 8 × 8 in size. The positions in which they are situated are known. It is guaranteed that none of them beats the other one. 22 23 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. 24 25 Input 26 27 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. 28 29 Output 30 31 Print a single number which is the required number of ways. 32 33 Examples 34 35 Input 36 37 ``` 38 a1 39 b2 40 ``` 41 42 Output 43 44 ``` 45 44 46 ``` 47 48 Input 49 50 ``` 51 a8 52 d4 53 ``` 54 55 Output 56 57 ``` 58 38 59 ```