KLUG1 - COUNT JUMPS


 

Mr. GopiKrishna want to count number of positions KNIGHT can move in a chessboard of size
nxm.He was too lazy in counting possible positions KNIGHT can move manually , so he needs
your help in finding possible positions.
Write a program that count possible movements of KNIGHT in chessboard of size nxm.

Mr. Krish want to count number of positions KNIGHT can move in a chessboard of size nxm.He was too lazy in counting possible positions ,knight can move manually , so he need your help in finding possible positions.

Help Mr.Krish to find total possibile positions knight can move from current position.

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 total number of possible positions knight can move

Note:

-chess board 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

hide comments
an6285: 2017-08-28 16:38:38

tutorial level :v

aditya_97: 2017-08-28 15:14:07

what could be the reason for run time error?

shahzada: 2017-08-28 14:08:38

tutorial

amulyagaur: 2017-08-28 12:43:16

Last edit: 2017-08-30 15:34:37
Vipul Srivastava: 2017-08-27 15:52:03

tutorial


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)