Problem:


Score : 100 points

Problem Statement

There is a grid with H horizontal rows and W vertical columns.
Let (i, j) denote the square at the i-th row from the top and the j-th column from the left.

For each i and j (1 \leq i \leq H, 1 \leq j \leq W), Square (i, j) is described by a character a_{i, j}.
If a_{i, j} is ., Square (i, j) is an empty square; if a_{i, j} is #, Square (i, j) is a wall square.
It is guaranteed that Squares (1, 1) and (H, W) are empty squares.

Taro will start from Square (1, 1) and reach (H, W) by repeatedly moving right or down to an adjacent empty square.

Find the number of Taro's paths from Square (1, 1) to (H, W).
As the answer can be extremely large, find the count modulo 10^9 + 7.

Constraints

H and W are integers.

2 \leq H, W \leq 1000

a_{i, j} is . or #.

Squares (1, 1) and (H, W) are empty squares.

Input

Input is given from Standard Input in the following format:

H W
a_{1, 1}\ldotsa_{1, W}
:
a_{H, 1}\ldotsa_{H, W}

Output

Print the number of Taro's paths from Square (1, 1) to (H, W), modulo 10^9 + 7.

Sample Input 1

3 4
...#
.#..
....

Sample Output 1

3

There are three paths as follows:

Sample Input 2

5 2
..
#.
..
.#
..

Sample Output 2

0

There may be no paths.

Sample Input 3

5 5
..#..
.....
#...#
.....
..#..

Sample Output 3

24

Sample Input 4

20 20
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................

Sample Output 4

345263555

Be sure to print the count modulo 10^9 + 7.



Sample input:
3 4
...#
.#..
....


Sample output:
3

Submission status: Wrong Answer

Solution code:
a=input().split()
H=int(a[0])
W=int(a[1])
n_list=[[0 for i in range(W)] for i in range(H)]
m_list=[]
for i in range(H) :
  m_list.append(input())

for i in range(H) :
  if m_list[i][0]=='.' :
    n_list[i][0]=1
    break

for i in range(W) :
  if m_list[0][i]=='.' :
    n_list[0][i]=1
    break

for i in range(1,H) :
  for j in range(1,W) :
    if m_list[i][j]=='#' :
      n_list[i][j]=0
    else :
      n_list[i][j]=n_list[i-1][j]+n_list[i][j-1]
print(n_list[-1][-1]%(10**9+7))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def nop(h,w):
    if l[h-1][w-1]=='#':
        return 0
    if h==1 or w==1:
        return 1
    return nop(h-1,w)+nop(h,w-1)
h,w=map(int,input().split())
l=[list(input()) for _ in range(h)]
print(nop(h,w)%(10**9+7))

Submission status: Wrong Answer

Solution code:
m = 10**9+7
def nCr(n,r):
  if r*2>n:
      return nCr(n,n-r)
  else:
      a = b = 1
      for i in range(r):
          a = a * (n - i) % m
          b = b * (r - i) % m
      return (a * pow(b,m-2,m)) % m

H,W=map(int,input().split())

grid=[]

for i in range(H):
    a= list(input())
    grid.append(a)

wall=[]
for i in range(H):
    for j in range(W):
        if grid[i][j]=="#":
            wall.append([i,j])

ans = nCr((H+W-2),(H-1))

for i in range(len(wall)):
    x = wall[i][0] + wall[i][1]
    y = (H-wall[i][0]) + (W-wall[i][1])
    ans -= nCr(x-1,wall[i][0]-1) * nCr(y-1,(H-wall[i][0])-1)

print(ans%m)

Submission status: Wrong Answer

Solution code:
m = 10**9+7
def nCr(n,r):
  if r*2>n:
      return nCr(n,n-r)
  else:
      a = b = 1
      for i in range(r):
          a = a * (n - i) % m
          b = b * (r - i) % m
      return (a * pow(b,m-2,m)) % m

H,W=map(int,input().split())

grid=[]

for i in range(H):
    a= list(input())
    grid.append(a)

wall=[]
for i in range(H):
    for j in range(W):
        if grid[i][j]=="#":
            wall.append([i,j])

ans = nCr((H+W-2),(H-1))

for i in range(len(wall)):
    x = wall[i][0] + wall[i][1]
    y = (H-wall[i][0]) + (W-wall[i][1])
    ans -= nCr(x-1,wall[i][0]-1) * nCr(y-1,(H-wall[i][0])-1)

print(ans//m)

Submission status: Wrong Answer

Solution code:
import sys 
input = sys.stdin.readline

h, w = [int(x) for x in input().split()]
g = [list(input().rstrip()) for _ in range(h)]

dp = [[0]*w for _ in range(h)]

dp[0][0] = 1

for i in range(h):
    for j in range(w):
        if g[i][j] == "#":
            continue
        xy = [(i - 1, j), (i, j - 1)]
        for k in xy:
            x, y = k
            if 0 <= x < h and 0 <= y < w:
                dp[i][j] += dp[x][y]

print(dp[-1][-1])

Submission status: Wrong Answer

Solution code:
#H-Grid1
H,W = map(int,input().split())
DP_1 = []
for _ in range(H):
    A = input()
    DP_1.append(A)

dp = [[1 for j in range(W)] for i in range(H)]
dp[0][0]=1
for i in range(1,H):
    for j in range(1,W):
        if DP_1[i-1][j]=="#":
            dp[i-1][j]=0
        elif DP_1[i][j-1]=="#":
            dp[i][j-1]=0
        dp[i][j] = dp[i-1][j] + dp[i][j-1]

print(dp[H-1][W-1])

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

H, W = map(int,input().split())
#A = [list(map(int,input().split())) for _ in range(H)]
A = np.array([list(input()) for _ in range(H)], 'U1')
eq = A == '.'

dp = np.zeros((H+1,W+1), dtype=int)
#np.zeros(W+1, dtype=int)
dp[0][1] = 1

for i in range(H):
    for j in range(W):
        if eq[i][j]:
            dp[i+1][j+1] = dp[i][j+1] + dp[i+1][j]
#            print(i,j,dp[i])
#            if i == 0 and j== 0:
#                dp[i+1][j+1] = 1
#    dp[i+1] %= mod

print(dp[-1][-1]%mod)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

H, W = map(int,input().split())
#A = [list(map(int,input().split())) for _ in range(H)]
A = np.array([list(input()) for _ in range(H)], 'U1')
eq = A == '.'

dp = np.zeros(W+1, dtype=int)
dp[1] = 1

for i in range(1,H+1):
    prev = dp.copy()
    for j in range(1,W+1):
        if eq[i-1][j-1]:
            dp[j] = prev[j] + dp[j-1]
        else:
            dp[j] = 0
#    dp %= mod

print(dp[-1]%mod)

Submission status: Wrong Answer

Solution code:

import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

H, W = map(int,input().split())
#A = [list(map(int,input().split())) for _ in range(H)]
A = np.array([list(input()) for _ in range(H)], 'U1')
eq = A == '.'

dp = np.zeros((H+1,W+1), dtype=int)
#np.zeros(W+1, dtype=int)
dp[1][1] = 1

for i in range(H):
    for j in range(W):
        if eq[i][j]:
            dp[i+1][j+1] = dp[i][j+1] + dp[i+1][j]
#            print(i,j,dp[i])
            if i == 0 and j== 0:
                dp[i+1][j+1] = 1
    dp[i] %= mod

print(dp[-1][-1])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	H_fix
# CreatedDate:  2020-04-15 22:50:55 +0900
# LastModified: 2020-04-15 23:10:26 +0900
#


import numpy as np


def main():
    h,w=map(int,input().split())
    dp = np.full((h,w),-1)
    dp[0,:]=1
    dp[:,0]=1
    for i in range(h):
        lined = input()
        for j in range(w):
            if lined[j]=='#':
                dp[i,j]=0
    for i in range(h):
        if dp[i,0]==0:
            dp[i:,0]=0
            break
    for i in range(w):
        if dp[0,i]==0:
            dp[0,i:]=0


#    print(dp)
    for i in range(h-1):
        for j in range(w-1):
            if dp[i+1,j+1]==0:
                dp[i+1,j+1]=0
            else:
                dp[i+1,j+1]=dp[i+1,j]+dp[i,j+1]
    print(dp[h-1,w-1]%(1000000007))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

h,w = map(int,readline().split())
maze = []
for _ in range(h):
	maze.append(readline().rstrip().decode('utf-8'))

dp = [[0]*w for _ in range(h)]
dp[0][0] = 1
for i in range(h):
	for j in range(w):
		if maze[i][j] == "#":
			continue
		if i > 0:
			dp[i][j] += dp[i-1][j]
		if j > 0:
			dp[i][j] += dp[i][j-1]

print(dp[-1][-1])

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
A = [input() for _ in range(H)]
dp = [[0] * W for _ in range(H)]
dp[0][0] = 1

for y in range(0, H):
    for x in range(0, W):
        if A[y][x] == '#':
            continue

        if x - 1 >= 0:
            dp[y][x] += dp[y][x-1]
        if y - 1 >= 0:
            dp[y][x] += dp[y-1][x]
#print(*dp, sep='\n')
print(dp[-1][-1])

Submission status: Wrong Answer

Solution code:
h,w = map(int, input().split())

a = [input() for _ in range(h)]
dp = [[0]*w for _ in range(h)]

dp[0][0] = int(a[0][0] == '.')

for i in range(1,h):
    dp[i][0] = int(a[i][0] == ".")*dp[i-1][0]
for j in range(1,w):
    dp[0][j] = int(a[0][j] == ".")*dp[0][j-1]

for i in range(1, h):
    for j in range(1, w):
        dp[i][j] = int(a[i][j]=='.') * (dp[i - 1][j] + dp[i][j - 1])
# for i in dp:
#     print(*i)

print(dp[h-1][w-1])

Submission status: Wrong Answer

Solution code:
#dph
h, w = map(int, input().split())
a = [['#' for _ in range(w+2)]]
for _ in range(h):
	l = ['#']
	m = list(input())
	l += m
	l.append('#')
	a.append(l)
a.append(['#' for _ in range(w+2)])

dp = [[0 for _ in range(w+2)] for _ in range(h+2)]

cnt = [[0 for _ in range(w+2)] for _ in range(h+2)]
for i in range(1,h+1):
	for j in range(1,w+1):
		if a[i-1][j] == '#':
			cnt[i][j] += 1
		if a[i][j-1] == '#':
			cnt[i][j] += 1

dp[1][1] = 1

def dfs(x, y):
	if a[x+1][y] == '.':
		dp[x+1][y] += dp[x][y]
		cnt[x+1][y] += 1
		if cnt[x+1][y] == 2:
			dfs(x+1, y)
	if a[x][y+1] == '.':
		dp[x][y+1] += dp[x][y]
		cnt[x][y+1] += 1
		if cnt[x][y+1] == 2:
			dfs(x, y+1)
	return
print(dp[h][w])

Submission status: Wrong Answer

Solution code:
import numpy as np

MOD = 10 ** 9 + 7

H, W = map(int, input().split())
count = np.ones((H, W), dtype=np.int)

row = input()
for w in range(1, W):
  if row[w] == '#':
    count[w:] = 0
    break

flag = True
for h in range(1, H):
  row = input()
  if flag and row[0] == '#':
    count[h:, 0] = 0
    flag = False
  count[h, 1:] = count[h-1, 1:]
  for w in range(1, W):
    period = 0
    if row[w] == '#':
      count[h, period : w] = count[h, period : w].cumsum() % MOD
      count[h, w] = 0
      period = w + 1
  count[h, period:] = count[h, period:].cumsum() % MOD
print(count[-1, -1])

Submission status: Wrong Answer

Solution code:
R, C = tuple(map(int, input().split()))
grid = [list(input()) for _ in range(R)]
dp = [[0 for _ in range(C)] for _ in range(R)]
for row in range(R):
    if grid[row][0] != '#':
        dp[row][0] = 1
    else:
        break
        
for col in range(C):
    if grid[0][col] != '#':
        dp[0][col] = 1
    else:
        break

def simplify(paths, MAX=10**9+7):
    while paths > MAX:
        paths -= MAX
    return paths
def gridpaths(R, C, grid):
    for row in range(1, R):
        for col in range(1, C):
            if grid[row][col] != '#':
                dp[row][col] = dp[row-1][col] + dp[row][col-1]
        #print(dp)
    return simplify(dp[-1][-1])

gridpaths(R, C, grid)

Submission status: Wrong Answer

Solution code:
from collections import deque

h,w = map(int,input().split())
m = []
for i in range(h):
  m.append(list(input()))

  
dp = [[0 for _ in range(w)] for _ in range(h)]

d = deque()
dx = [0,1]
dy = [1,0]
m[0][0] = '-'


d.appendleft([0,0])
dp[0][0] = 1
while d:
  c = d.pop()
  cx = c[0]
  cy = c[1]
  for o in range(2):
    bx = cx - dx[o]
    by = cy - dy[o]
    
    if bx >= 0 and by >= 0 and m[by][bx] != '#':
      dp[cy][cx] += dp[by][bx]
    
  for i in range(2):
    nx = cx + dx[i]
    ny = cy + dy[i]
    
    if nx < w and ny < h and  m[ny][nx] != '#' and m[ny][nx] != '-':
      m[ny][nx] = '-'
      d.appendleft([nx,ny])

print(dp[h-1][w-1])

Submission status: Wrong Answer

Solution code:
from collections import deque

h,w = map(int,input().split())
m = []
for i in range(h):
  m.append(list(input()))

  
dp = [[0 for _ in range(w)] for _ in range(h)]

d = deque()
dx = [0,1]
dy = [1,0]
m[0][0] = '-'


d.appendleft([0,0])
dp[0][0] = 1
while d:
  c = d.pop()
  cx = c[0]
  cy = c[1]
  for o in range(2):
    bx = cx - dx[o]
    by = cy - dy[o]
    
    if bx >= 0 and by >= 0 and m[by][bx] != '#':
      dp[cy][cx] += dp[by][bx]
    
  for i in range(2):
    nx = cx + dx[i]
    ny = cy + dy[i]
    
    if nx < w and ny < h and  m[ny][nx] != '#' and m[ny][nx] != '-':
      m[ny][nx] = '-'
      d.appendleft([nx,ny])

print(dp)

Submission status: Wrong Answer

Solution code:
h,w = [int(x) for x in input().split()]
m = []
for _ in range(h):
    m.append(list(input()))
mod = 10**9+7
dp = [[0]*w for _ in range(h)]
dp[0][0] = 1
for i in range(h):
    for j in range(w):
        if i+1<h and m[i+1][j]==".":
            dp[i+1][j] += dp[i][j]
        if j+1<w and m[i][j+1]==".":
            dp[i][j+1] += dp[i][j]

print(dp[-1][-1])

Submission status: Wrong Answer

Solution code:
import math
import sys
sys.setrecursionlimit(1000000)
dp = [[0]*(1000+1) for x in range(1000+1)]
tab = []
def main():
    global n,m
    n,m = map(int,input().split())
    
    for x in range(n):
        tab.append(input())
    
    for x in range(n):
        for y in range(m):
            if tab[x][y]=="#":
                continue
            elif x==0 or y==0:
                dp[x][y] = 1
            else:
                dp[x][y] = dp[x][y-1] + dp[x-1][y]
    
    print(dp[n-1][m-1]%(10**9+7))
main()

Submission status: Wrong Answer

Solution code:
h,w = map(int, input().split())

bignum = pow(10,9) + 7

mee = [[0 for i in range(w+1)] for j in range(h)]
#starting should all be 1
#walled = -1

for j in range(h):
    mee[j][0] = 0


for i in range(h):
    temp = input()
    for j in range(w):
        if temp[j] == "#":
            mee[i][j+1] = -1

for i in range(w+1):
    if mee[0][i] == -1:
        break
    mee[0][i] = 1

for i in range(h):
    print(mee[i])


#from top and from left >0 --> +1
#
for i in range(1,h):
    for j in range(1,w+1):
        if mee[i][j] == -1:
            continue
        if mee[i - 1][j] > 0 and mee[i][j - 1] > 0:
            mee[i][j] = mee[i - 1][j] % bignum + mee[i][j - 1] %bignum

        elif mee[i - 1][j] > 0 or mee[i][j - 1] >0:
            mee[i][j] = max(mee[i-1][j],mee[i][j-1])

for i in range(h):
    print(mee[i])
print(mee[-1][-1] % bignum)

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
c=[]
for i in range(h):
  c+=[list(input())]
d=[[0]*w]*h
d[0][0]=1
for i in range(1,w):
  d[0][i]=d[0][i-1]*(c[0][i]=='.')
for i in range(1,h):
  d[i][0]=d[i-1][0]*(c[i][0]=='.')
for i in range(1,h):
  for j in range(1,w):
    d[i][j]=(d[i][j-1]+d[i-1][j])*(c[i][j]=='.')
print(d[-1][-1]%(10**9+7))

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
A = []
mod = 10**9
mod += 7
print(mod)
for h in range(H):
	A.append(list(input()))
dp = [[0 for w in range(W)] for h in range(H)]
dp[0][0] = 1
for i in range(H):
	for j in range(W):
		if A[i][j] != "#":
			if i > 0 and A[i-1][j] != '#':
				dp[i][j] = (dp[i][j]%mod + dp[i-1][j]%mod)%mod
			if j > 0 and A[i][j-1] != '#':
				dp[i][j] = (dp[i][j]%mod + dp[i][j-1]%mod)%mod
# print(dp)
print(dp[H-1][W-1])

Submission status: Wrong Answer

Solution code:
from collections import deque
mod=10**9+7
H,W = map(int,input().split())
Gd = [list(input()) for _ in range(H)]
INF = 0
direc = [[1,0],[0,1]]
def dfs(start):
  Rt = [[INF]*W for _ in range(H)]
  Rt[start[0]][start[1]]=1
  q = deque([])# スタック
  q.append(start)
  while len(q)!=0:
    h,w = q.pop()# スタック取りだし（後ろ）
    for d in direc:
      hs, ws = h + d[0], w + d[1]
      if not (0<=hs<H and 0<=ws<W):
        continue
      if Gd[hs][ws]=='.':
        if Rt[hs][ws]==INF:
          q.append([hs,ws])
        Rt[hs][ws] = (Rt[hs][ws] + Rt[h][w])%mod
  return Rt[H-1][W-1]
print(dfs([0,0]))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)

H, W = map(int, input().split())
field = [list(input()) for _ in range(H)]

count = [0]
dp = [[-1] * W for _ in range(H)]

def dfs(x, y):
  ret = 0
  for nx, ny in ((1,0), (0,1)):
    nx += x
    ny += y
    if nx == W-1 and ny == H-1:
      ret += 1
      continue
    elif nx >= W or ny >= H:
      continue
    elif dp[ny][nx] > -1:
      ret += dp[ny][nx]
      continue
    elif field[ny][nx] == "#":
      continue
    else:
      ret += dfs(nx, ny)
  dp[y][x] = ret
  return ret

dfs(0,0)
print(dp[0][0])

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)

H, W = map(int, input().split())
field = [list(input()) for _ in range(H)]

count = [0]
dp = [[-1] * W for _ in range(H)]

def dfs(x, y):
  ret = 0
  for nx, ny in ((1,0), (0,1)):
    nx += x
    ny += y
    if nx == W-1 and ny == H-1:
      return ret + 1
    if nx >= W or ny >= H:
      continue
    if dp[ny][nx] > -1:
      ret += dp[ny][nx]
      continue
    if field[ny][nx] == "#":
      continue
    ret += dfs(nx, ny)
  dp[y][x] = ret
  return ret

dfs(0,0)
print(dp[0][0])

Submission status: Wrong Answer

Solution code:
import sys
input == sys.stdin.readline

def main():
    """dpをするときのてんぷれコ―ド"""
    #1:初期化
    mod = 10**9+7
    H, W = map(int, input().split())
    a = []
    for _ in range(H):
        a.append(input())
    dp = [[0]*(W) for _ in range(H)]

    #2:初期値
    dp[0][0] = 1

    print(a[0][1], ".", a[0][0]==".")

    #3:dp実行部(貰うDP)
    for i in range(H):
        for j in range(W):
            if a[i][j] == ".":             
                if i == 0 and j == 0:
                    continue
                elif i == 0 and a[i][j-1] == ".":
                    dp[i][j] += dp[i][j-1]
                elif j == 0 and a[i-1][j] == ".":
                    dp[i][j] += dp[i-1][j]
                else:
                    if a[i][j-1] == ".":
                        dp[i][j] += dp[i][j-1]
                    if a[i-1][j] == ".":
                        dp[i][j] += dp[i-1][j]

    #print(*dp,sep="\n")

    #4:出力
    print(dp[H-1][W-1] % mod)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

def main():
    h,w=map(int,input().split())
    s=[list(input()) for _ in range(h)]
    dp=[[0]*w for _ in range(h)]
    dp[1][1]=1
    for j in range(w):
        for i in range(h):
            if s[i][j]=='#':
                continue
            else:
                if j==0:
                    dp[i][j]=dp[i-1][j]%(10**9+7)
                elif i==0:
                    dp[i][j]=dp[i][j-1]%(10**9+7)
                else:
                    dp[i][j]=(dp[i-1][j]+dp[i][j-1])%(10**9+7)
    print(dp[h-1][w-1])

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from collections import deque

def main():
    h,w=map(int,input().split())
    s=[list(input()) for _ in range(h)]
    dp=[[0]*w for _ in range(h)]
    dp[1][1]=1
    for j in range(w):
        for i in range(h):
            if s[i][j]=='#':
                continue
            else:
                if j==0:
                    dp[i][j]=dp[i-1][j]
                elif i==0:
                    dp[i][j]=dp[i][j-1]
                else:
                    dp[i][j]=dp[i-1][j]+dp[i][j-1]
    print(dp[h-1][w-1])

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
H, W = [int(item) for item in input().split()]
grid = [[item for item in input().strip()] for _ in range(H)]

# print(H, W) 
# print(grid)

dp = [[0 for _ in range(W+1)] for _ in range(H+1)]
dp[0][1] = 1

for i in range(H):
    for j in range(W):
        if grid[i][j] == '#':
            pass
        else:
            dp[i+1][j+1] = dp[i][j+1] + dp[i+1][j]

print(dp[H][W])

Submission status: Wrong Answer

Solution code:
import numpy as np

H, W = [int(item) for item in input().split()]

grid = np.array([[item for item in input()] for _ in range(H)])
dp = np.zeros((H+1, W+1), dtype='int32')
max_num = 10**9 +7

def main():
    dp[0,1] = 1

    for i in range(H):
        for j in range(W):
            if grid[i, j] == '#':
                continue

            dp[i+1, j+1] = (dp[i+1, j] + dp[i, j+1]) % max_num

    print(dp)
    print(dp[H,W])

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy
MAX = 10**9 + 7

def main():
  h, w = map(int, input().strip().split())
  dp = numpy.full((h, w), 0)
  maze = [input().strip() for _ in range(h)]
  def fill(xs, iright, x=1):
    if iright >= 0:
      xs[:iright] = x
    else:
      xs = x
    return xs
  dp[0] = fill(dp[0], maze[0].find('#'))
  dp[:, 0] = fill(dp[:, 0], ''.join([maze[i][0] for i in range(h)]).find('#'))

  for i in range(1, h):
    for j in range(1, w):
      if maze[i][j] == '#':
        continue
      dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MAX
  print(dp[-1][-1])


if __name__=='__main__':
  main()

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
gridlist = [list(input()) for i in range(H)]

for each in gridlist:
    print(each)

matrix = [[1]*W for i in range(H)]

print(matrix)
for i in range(H):
    for j in range(W):
        if gridlist[i][j] == '#':
            matrix[i][j] = 0

# print(matrix)

for i in range(H):
    for j in range(W):
        up = 0
        left = 0
        if matrix[i][j] == 0:
            continue
        if i==0 and j == 0:
            continue
        if i > 0:
            left = matrix[i-1][j]
        if j > 0:
            up = matrix[i][j-1]
        matrix[i][j] = left + up
        # print(matrix)

print(matrix[i][j] % (10**9 + 7))

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
gridlist = [list(input()) for i in range(H)]

for each in gridlist:
    print(each)

matrix = [[1]*W for i in range(H)]

print(matrix)
for i in range(H):
    for j in range(W):
        if gridlist[i][j] == '#':
            matrix[i][j] = 0

# print(matrix)

for i in range(H):
    for j in range(W):
        up = 0
        left = 0
        if matrix[i][j] == 0:
            continue
        if i==0 and j == 0:
            continue
        if i > 0:
            left = matrix[i-1][j]
        if j > 0:
            up = matrix[i][j-1]
        matrix[i][j] = left + up
        # print(matrix)

print(matrix[i][j])

Submission status: Wrong Answer

Solution code:
H,W = map(int,input().split())
mod = 10**9+7
M = []
for i in range(H):
    M.append(input())
dp = [[0 for i in range(W)] for j in range(H)]
dp[0][0] = 1
for i in range(H):
    for j in range(W):
        if i != H-1 and M[i+1][j] == '.':
            dp[i+1][j] += dp[i][j] % mod
        if j != W-1 and M[i][j+1] == '.':
            dp[i][j+1] += dp[i][j] % mod
print(dp[-1][-1])

Submission status: Wrong Answer

Solution code:
H,W = map(int,input().split())
a = [list(input()) for _ in range(H)]

maze = [[0 for _ in range(W)] for _ in range(H)]

mm = 1
for w in range(W):
    if a[0][w] == '#':
        mm = 0
    maze[0][w] = mm

mm = 1
for h in range(H):
    if a[h][0] == '#':
        mm = 0
    maze[h][0] = mm

for h in range(1,H):
    for w in range(1,W):
        if a[h][w] == ".":
            maze[h][w] = maze[h-1][w]+maze[h][w-1]

print(maze[H-1][W-1])

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

h,w = inpl()
g = [input() for i in range(h)]
dp = [[0]*w for i in range(h)]
for i in range(h):
    if g[i][0] == '#':
        break
    dp[i][0] = 1
for i in range(w):
    if g[0][i] == '#':
        break
    dp[0][i] = 1

for y in range(h-1):
    for x in range(w-1):
        if g[y][x] == '#':
            continue
        dp[y+1][x+1] = dp[y+1][x] + dp[y][x+1]
        dp[y+1][x+1] %= mod
print(dp[-1][-1])

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
mod = 10**9 + 7
dp = [0]*((N+1)*(M+1))
dp[1] = 1
for i in range(1, N+1):
    s = input().strip()
    for j in range(1, M+1):
        if s[j-1] == ".":
            dp[i*(M+1)+j] = dp[(i-1)*(M+1) + j] + dp[i*(M+1) + j-1]
print(dp[N*(M+1)+M])

Submission status: Wrong Answer

Solution code:
a, b = list(map(int, input().split()))
grid = list()
grid.append([-1 for _ in range(b + 2)])
for t in range(0, a):
    grid.append([-1])
    line = list(input())
    for k in range(len(line)):
        if line[k] == '#':
            grid[t + 1] += [-1]
        else:
            grid[t + 1] += [0]
    grid[t + 1] += [-1]
grid.append([-1 for _ in range(b + 2)])
grid[1][1] = 1
for x in range(1, a + 1):
    for y in range(1, b + 1):
        if grid[x][y] > 0:
            if grid[x + 1][y] != -1:
                grid[x + 1][y] += grid[x][y]
            if grid[x][y + 1] != -1:
                grid[x][y + 1] += grid[x][y]
print(grid[-2][-2])

Submission status: Wrong Answer

Solution code:
h,w = map(int,input().split())
a = [list(map(str,input())) for _ in range(h)]
#dp[i][j]は上からi番目,左からj番目 dp[i+1][j+1] = dp[i][j+1]+dp[i+1][j]
mod = 10**9+7
dp = [[0]*w for i in range(h)]
for k in range(h):
  if a[k][0] == ".":
    dp[k][0] = 1
  else:
    break
for l in range(w):
  if a[0][l] == ".":
    dp[0][l] = 1
  else:
    break
for i in range(h-1):
  for j in range(w-1):
    dp[i+1][j+1] = (dp[i][j+1]+dp[i+1][j]) % mod
    if a[i][j] == "#":
      dp[i+1][j+1] = 0
print(dp[-1][-1])
#print(dp)

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    H,W=list(map(int,sys.stdin.readline().split()))
    MAP=[]
    for i in range(H):
        MAP.append([0 if x=="#" else 1 for x in sys.stdin.readline()][:-1])
    #1:道　0:ブロック

    dp=[[1]*W for _ in range(H)]

    for x in range(1,W):
        if MAP[0][x]:
            dp[0][x]=dp[0][x-1]
        else:
            dp[0][x]=-1


    for y in range(1,H):
        if MAP[y][0]:
            dp[y][0]=dp[y-1][0]
        else:
            dp[y][0]=-1

    for y in range(1,H):
        for x in range(1,W):
            if MAP[y][x]==0:
                dp[y][x]=-1
            else:
                o=0
                if dp[y][x-1]+1:
                    o+=dp[y][x-1]
                if dp[y-1][x]+1:
                    o+=dp[y-1][x]
                if not (dp[y-1][x]+1 or dp[y][x-1]+1):
                    o=-1
                else:
                    o%=10**9+7

                dp[y][x]=o

    print(dp[H-1][W-1])

main()

Submission status: Wrong Answer

Solution code:
H,W=map(int,input().split())
a=[]
dp=[[0 for i in range(W)] for j in range(H)]
dp[0][0]=1
for i  in range(H):
    a.append(list(input()))
for i in range(H):
    for j in range(W):
        u=0
        l=0
        if j>0 and a[i][j-1]!='#':
            l=dp[i][j-1]
        if i>0 and a[i-1][j]!='#':
            u=dp[i-1][j]
        dp[i][j]+=u+l
print(dp[H-1][W-1])

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
buf = sys.stdin.buffer
mod = 10 ** 9 + 7

H, W = map(int, buf.readline().split())

grid = np.resize(np.frombuffer(buf.read(), dtype='S1') == b'.', (H, W + 1))[:, :-1] * 1

for i in range(H - 1):
    for j in range(W - 1):
        if grid[i + 1][j + 1] != 0:
            grid[i + 1][j + 1] = (grid[i][j + 1] + grid[i + 1][j]) % mod

print(grid[-1][-1])

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

H,W = map(int,input().split())
mod = 10**9+7

A = [list(input().rstrip('/n')) for _ in range(H)]

dp = [[0]*W for _ in range(H)]
dp[0][0]=1
for h in range(H):
    for w in range(W):
        if (h+1<H and A[h][w] == '.'):
            dp[h+1][w] += dp[h][w]
        if (w+1<W and A[h][w]=='.'):
            dp[h][w+1] += dp[h][w]
print(dp[H-1][W-1])

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline

H,W = map(int,input().split())
mod = 10**9+7
li = [list(input().rstrip('/n')) for _ in range(H)]

dp = [[0]*W for _ in range(H)]

for h in range(H):
  for w in range(W):
    if (h+1<H and li[h][w] == '.'):
      dp[h+1][w] = dp[h][w]
    if (w+1<W and li[h][w] == '.'):
      dp[h][w+1] = dp[h][w]
    
print(dp[H-1][W-1] % mod)

Submission status: Wrong Answer

Solution code:
h,w = map(int,raw_input().split())

mat = [[0 for i in range(w)] for j in range(h)]

for i in range(h):
    st = raw_input()
    for j in range(len(st)):
        mat[i][j] = st[j]

dp = [[0 for i in range(w)] for j in range(h)]

dp[0][0] = 1

for i in range(h):
    if mat[i][0] != "#":
        dp[i][0] = 1
    else:
        break
for j in range(w):
    if mat[0][j] != "#":
        dp[0][j] = 1
    else:
        break

for i in range(1,h):
    for j in range(1,w):
        if mat[i-1][j-1] == "#":
            dp[i][j]=0
        else:
            dp[i][j] = dp[i-1][j] + dp[i][j-1]
print dp[h-1][w-1]

Submission status: Wrong Answer

Solution code:
H,W = [int(s) for s in input().split()]
dp = [[0]*(1001) for _ in range(1001)]
dp[0][0] = 1

a = [[0]*W for _ in range(H)]
for i in range(H):
    lis = list(input())
    for j in range(W):
        a[i][j] = lis[j]

for i in range(H):
    for j in range(W):
        if i+1 < H and a[i+1][j] == '.':
            dp[i+1][j] += dp[i][j]
        if j+1 < W and a[i][j+1] == '.':
            dp[i][j+1] += dp[i][j]

print(dp[H-1][W-1])

Submission status: Wrong Answer

Solution code:
H,W = [int(s) for s in input().split()]
dp = [[0]*(1001) for _ in range(1001)]
dp[0][0] = 1

a = [[0]*W for _ in range(H)]
for i in range(H):
    lis = list(input())
    for j in range(W):
        a[i][j] = lis[j]

for i in range(H):
    for j in range(W):
        if a[i][j] == '.':
            dp[i+1][j] += dp[i][j]
        elif a[i][j] == '.':
            dp[i][j+1] += dp[i][j]

print(dp[H][W])

Submission status: Wrong Answer

Solution code:
R, C = map(int, input().split())
arr = [list(input()) for _ in range(R)]
dp = [[0 for _ in range(C+1)] for _ in range(R+1)]
dp[1][1] = 1
for i in range(1, R+1):
    for j in range(1, C+1):
        if arr[i-1][j-1] == "#":
            dp[i][j] = 0
        else:
            dp[i][j] = max(dp[i][j], dp[i-1][j]+dp[i][j-1])

print(dp[-1][-1])

Submission status: Wrong Answer

Solution code:
N, M = list(map(int, input().split()))
F = []
for i in range(N):
    F.append(input())
W = [[0] * M for _ in range(N)]
for i in range(N):
    W[i][0] = 1
for i in range(M):
    W[0][i] = 1
for i in range(1, N):
    for j in range(1, M):
        if F[i-1][j] != "#":
            W[i][j] += W[i-1][j]
        if F[i][j-1] != "#":
            W[i][j] += W[i][j-1]
print(W[-1][-1])

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
a = [input() for _ in range(H)]

dp = [[0] * W for _ in range(H)]
dp[0][0] = 1
for w in range(1, W):
  if a[0][w] != '#':
    dp[0][w] = dp[0][w - 1]

for h in range(1, H):
  if a[h][0] != '#':
    dp[h][0] = dp[h - 1][0]
  for w in range(1, W):
    if a[h][w] != '#':
      dp[h][w] = dp[h][w - 1] + dp[h - 1][w]

print(dp[H - 1][W - 1])

Submission status: Wrong Answer

Solution code:
H,W = map(int,input().split())
a = [input() for _ in range(H)]
dp = [[0 for _ in range(W+1)] for __ in range(H+1)]
dp[1][0]=1
for h in range(1,H+1):
    for w in range(1,W+1):
        if a[h-1][w-1]=='#':
            continue
        else:
            dp[h][w] = dp[h-1][w] + dp[h][w-1]
print(dp[H][W])