Submit | All submissions | Best solutions | Back to list |
KLUG1 - COUNT JUMPS |
Mr. Krish wants to count number of positions a knight can move in a chessboard of size n × m. He was too lazy to count possible positions manually, so he needs your help in finding the number of possible positions.
Help Mr. Krish to find total possible positions knight can move from current position in one move.
Constraints
1 <= n, m <= 100
1 <= a <= n
1 <= b <= m
Input
First line contains n and m. Where n is number of rows and m is number of columns of chessboard.
Next n lines contains 1’s and 0’s.
Next line contains a, b (current position of the knight)
Output
Print the number of possible positions knight can move to in one move.
Note:
Chessboard filled with only 1’s and 0’s:
- 1 means that position is filled i.e. knight can't move to filled position.
- 0 means knight can move to that position (empty position).
1-based indexing.
Example
Input: 4 4 1 0 1 0 0 1 1 1 1 1 0 1 0 1 1 1 3 3 Output: 4
Added by: | gopikrishna_p |
Date: | 2017-08-25 |
Time limit: | 0.100s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
Resource: | https://en.wikipedia.org/wiki/Knight_(chess) |
hide comments
2022-06-18 03:40:33 David
@khoaph - no route. Print number of positions. the knight can move in one move. This answer is 0 to 8, depending on location of knight and filled positions. Java slow. TLE - then resubmit without changes and AC! |
|
2018-06-03 10:26:42
I don't understand the problem, can anyone show me the routes the knight can move? |
|
2018-05-06 18:45:11
Print number of positions the knight can move to in ONE MOVE. -1 for this waste of time. |
|
2017-08-28 16:38:38
tutorial level :v |
|
2017-08-28 15:14:07
what could be the reason for run time error? |
|
2017-08-28 14:08:38 shahzada
tutorial |
|
2017-08-27 15:52:03 Vipul Srivastava
tutorial |