题解 | #[NOIP2002 普及组] 过河卒#
[NOIP2002 普及组] 过河卒
http://www.nowcoder.com/practice/cc1a9bc523a24716a117b438a1dc5706
n,m,x,y=map(int,input().split())
assert(1<=n<=20)
assert(1<=m<=20)
assert(0<=x<=20)
assert(0<=y<=20)
board=[[1 for _ in range(0,m+1)] for _ in range(0,n+1)]
for x1 in range(x-3,x+4):
for y1 in range(y-3,y+4):
if abs(x1-x)+abs(y1-y)==3:
if 0<=x1<=n and 0<=y1<=m and x1!=x and y1!=y:
board[x1][y1]=0
if x<=n and y<=m:
board[x][y]=0
for k in range(1,m+1):
if board[0][k]!=0:
board[0][k]=board[0][k-1]
for k in range(1,n+1):
if board[k][0]!=0:
board[k][0]=board[k-1][0]
for i in range(1,n+1):
for j in range(1,m+1):
if board[i][j]!=0:
board[i][j]=board[i-1][j]+board[i][j-1]
print(board[n][m])