Roger has finally finished running the DMPG and returns to one of his hobbies, playing chess.
Victor has given Roger the following chess-themed math problem: Given an
Constraints
Input Specification
The first line will contain two integers,
Each of the next
- 0 represents a neutral square
- 1 represents a good square
- 2 represents an evil square
- 3 represents a good square and the source for the knight
- 4 represents a good square and the destination for the knight
Output Specification
Output either one or two lines. If it is impossible to construct a path for the knight,
output one line containing exactly -1
.
Otherwise, output two lines. The first line should be a single integer, the minimum number of squares to convert. The second line should be a single integer, the number of ways to convert that many squares to yield a valid path.
Sample Input
4 5
1 0 0 0 0
3 0 0 0 0
0 0 2 0 0
0 0 0 4 0
Sample Output
2
3
Comments
why can't the problem name just be "Roger Plays Chess"? why does it have to be "Roger Just Plays Chess"?
why can't Roger just play chess? Why does he have to play some chess? WTS. very :angry: