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:
mod = 10**9+7
H,W = map(int,input().split())
maze = [list(input()) 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 i+1<H and maze[i+1][j]==".":
            dp[i+1][j] += dp[i][j]%mod
        if j+1<W and maze[i][j+1]==".":
            dp[i][j+1] += dp[i][j]%mod
            
print(dp[H-1][W-1])

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
grid = []
d = [(1, 0), (0, 1)]
for _ in range(H):
    grid.append(input())
dp = [[0 for _ in range(W)] for _ in range(H)]
mod = 1e9 + 7
dp[0][0] = 1
for h in range(H):
    for w in range(W):
        if grid[h][w] == '#':
            continue
        if h > 0 and grid[h - 1][w] == '.':
            dp[h][w] += dp[h - 1][w] % mod
        if w > 0 and grid[h][w - 1] == '.':
            dp[h][w] += dp[h][w - 1] % mod
print(int(dp[H - 1][W - 1]))

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/dp/tasks/dp_h

H, W = map(int, input().split())
grid = []
d = [(1, 0), (0, 1)]
for _ in range(H):
    grid.append(input())
dp = [[0 for _ in range(W)] for _ in range(H)]
dp[0][0] = 1
for h in range(H):
    for w in range(W):
        if grid[h][w] == '#':
            continue

        if h > 0 and w > 0 and grid[h - 1][w] == '.' and grid[h][w - 1] == '.':
            dp[h][w] = dp[h - 1][w] + dp[h][w - 1]
        elif h > 0 and grid[h - 1][w] == '.':
            dp[h][w] = dp[h - 1][w]
        elif w > 0 and grid[h][w - 1] == '.':
            dp[h][w] = dp[h][w - 1]
print(dp[H - 1][W - 1])

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())

A_map = []
for i in range(H):
    A_str = input()
    A_map.append(A_str)

dp = [[0] * W for _ in range(H)]
dp[0][0] = 1
dire = [[1,0], [0,1]] #下　右

for i in range(H):
    for j in range(W):
        if A_map[i][j] == '#':
            continue
        for k in dire:
            if 0 <= i+k[0] <= H-1 and  0 <= j+k[1] <= W-1:
                if A_map[i+k[0]][j+k[1]] == '.':
                    dp[i+k[0]][j+k[1]] +=  dp[i][j]
#print(dp)
print(dp[H-1][W-1])

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**7)

def grid(y,x):
    global dp
    if mp[y][x]!='#' and dp[y][x]==0:
        dp[y][x]=grid(y-1,x)+grid(y,x-1)
        return dp[y][x]
    else:
        return 0


H,W=map(int,input().split())
mp=[['#']*(W+1)]
for _ in range(H):
    mp.append(['#']+list(input()))
mp.append(['#']*(W+1))

dp=[[0]*(W+1)for _ in range(H+1)]
dp[1][1]=1
grid(H,W)
print(dp[H][W]%(10**9+7))

Submission status: Wrong Answer

Solution code:
def grid(maze,h,w):
    mod = 7+10**9
    visited = [[0]*w for _ in range(h)]
    for i in range(h):
        for j in range(w):
            if maze[i][j] == "#":
                continue

            if i==0 and j==0:
                visited[i][j] = 1
            
            if i == 0:
                visited[i][j] = visited[i][j-1]
            elif j == 0:
                visited[i][j] = visited[i-1][j]
            else:
                visited[i][j] = (visited[i-1][j]%mod + visited[i][j-1]%mod)%mod
    
    return visited[h-1][w-1]


h,w = map(int,input().split())

maze = []

for _ in range(h):
    maze.append(list(input()))

print(grid(maze,h,w))

Submission status: Wrong Answer

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
# import numpy as np
starttime = time.time()
# import numpy as np
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]

try:
    sys.setrecursionlimit(int(pow(10,6)))
    sys.stdin = open("input.txt", "r")
    # sys.stdout = open("../output.txt", "w")
except:
    pass


n,m=L()
A=[input() for i in range(n)]
dp=[[0 for i in range(m)] for j in range(n)]
for i in range(n):
    for j in range(m):
        if i==0 and j==0:
            dp[i][j]=1
            continue
        if i==0:
            if A[i][j]==".":
                dp[i][j]=dp[i][j-1]
        elif j==0:
            if A[i][j]==".":
                dp[i][j]=dp[i-1][j]
        else:
            if A[i][j]==".":
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod
            else:
                dp[i][j]=0
    print(*dp[i])
print(dp[-1][-1])



endtime = time.time()
# print(f"Runtime of the program is {endtime - starttime}")

Submission status: Wrong Answer

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
# import numpy as np
starttime = time.time()
# import numpy as np
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]

try:
    sys.setrecursionlimit(int(pow(10,6)))
    sys.stdin = open("input.txt", "r")
    # sys.stdout = open("../output.txt", "w")
except:
    pass


n,m=L()
A=[input() for i in range(n)]
dp=[[0 for i in range(m)] for j in range(n)]
for i in range(n):
    for j in range(m):
        if i==0 and j==0:
            dp[i][j]=1
            continue
        if i==0:
            dp[i][j]=dp[i][j-1]
        elif j==0:
            dp[i][j]=dp[i-1][j]
        else:
            if A[i][j]==".":
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod
            else:
                dp[i][j]=0
print(dp[-1][-1])



endtime = time.time()
# print(f"Runtime of the program is {endtime - starttime}")

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
grid = [list('#' * (W+1))]
for _ in range(1, H+1):
    temp = list(input())
    temp = ['#'] + temp
    grid.append(temp)
dp = [[0] * (W+1) for _ in range(H+1)]
dp[0][1] = 1

for i in range(1, H+1):
    for j in range(1, W+1):

        if grid[i][j] == '.':
            dp[i][j] = dp[i][j-1] + dp[i-1][j]

print(dp[H][W])

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

grid = [None]*n

for i in range(n):
    grid[i] = list(input())

dp = [[0]*m for _ in range(n)]

dp[0][0] = 1

for i in range(n):
    if grid[i][0] != '#':
        dp[i][0] = 1
    else:
        break

for i in range(m):
    if grid[0][i] != '#':
        dp[0][i] = 1
    else:
        break

for i in range(1, n):
    for j in range(1, m):
        if grid[i][j] == '#':
            continue

        dp[i][j] = dp[i-1][j] + dp[i][j-1]

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

Submission status: Wrong Answer

Solution code:
from collections import deque

h, w = map(int, input().split())
maze = [[0]*w for _ in range(h)]
for i in range(h):
  for j, r in enumerate(input()):
    if r == "#":
      maze[i][j] = 1

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

D = deque()
D.append((0, 0))

dxdy = [(0, 1), (1, 0)]

appended =  [[False]*w for _ in range(h)]
appended[0][0] = True
while D:
  p = D.popleft()
  if p == (h-1, w-1):
    break
  for k in range(2):
    nx = p[0] + dxdy[k][0]
    ny = p[1] + dxdy[k][1]
    if 0<=nx<h and 0<=ny<w and maze[nx][ny]==0:
      cnt[nx][ny] += cnt[p[0]][p[1]]
      if appended[nx][ny]==False:
        D.append((nx, ny))
        appended[nx][ny] = True

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

Submission status: Wrong Answer

Solution code:

def mod(num):
    return num % (10 ** 9 + 7)

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

for i in range(H):
    a = input()
    for j in range(W):
        if a[j] == "#":
            dp[i][j] = -1

dp[0][0] = 1

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

for row in range(1, H):
    for col in range(W):
        if dp[row][col] != -1:
            if col == 0:
                dp[row][col] = dp[row - 1][col]
            else:
                dp[row][col] = mod(dp[row - 1][col] + dp[row][col - 1])
        else:
            dp[row][col] = 0

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Jul 26 15:42:52 2020

@author: tinku
"""
def converter(arr,m,n):
    new_arr=[[0 for i in range(n)] for j in range(m)]
    for i in range(m):
        for j in range(n):
            if arr[i][j]=='.':
                new_arr[i][j]=0
            else:
                new_arr[i][j]=1
    return new_arr
            
m,n=map(int,input().split())
arr=[]
for i in range(m):
    arr.append(input())
arr=converter(arr,m,n)
if arr[0][0]==1 or arr[m-1][n-1]==1:
    print(0)
else:
    arr[0][0]=1
    for i in range(1,m):
        arr[i][0]=int(arr[i-1][0]==1 and arr[i][0]==0)
    for i in range(1,n):
        arr[0][i]=int(arr[0][i-1]==1 and arr[0][i]==0)
    for i in range(1,m):
        for j in range(1,n):
            if arr[i][j]==0:
                arr[i][j]=arr[i-1][j] + arr[i][j-1]
            else:
                arr[i][j]=0
    print(arr[m-1][n-1])

Submission status: Wrong Answer

Solution code:
NUM=10**9+7
H,W=list(map(int,input().split()))
matrix=[]
for i in range(H):
    matrix.append(list(input()))
dp=[[0]*W for i in range(H)]
for i in range(W):
    if(matrix[0][i]=='#'):
        dp[0][i]=0
    else:
        dp[0][i]=dp[0][i-1]
for j in range(1,H):
    if(matrix[j][0]=='#'):
        dp[j][0]=0
    else:
        dp[j][0]=dp[j-1][0]
for i in range(1,H):
    for j in range(1,W):
        if(matrix[i][j]=='#'):
            dp[i][j]=0
        else:
            dp[i][j]=(dp[i-1][j] + dp[i][j-1])%NUM 
print(dp[H-1][W-1]%NUM)

Submission status: Wrong Answer

Solution code:
NUM=10**9+7
H,W=list(map(int,input().split()))
matrix=[]
for i in range(H):
    matrix.append(list(input()))
dp=[[0]*W for i in range(H)]
for i in range(W):
    if(matrix[0][i]=='#'):
        dp[0][i]=0
    else:
        dp[0][i]=1
for j in range(1,H):
    if(matrix[j][0]=='#'):
        dp[j][0]=0
    else:
        dp[j][0]=1
for i in range(1,H):
    for j in range(1,W):
        if(matrix[i][j]=='#'):
            dp[i][j]=0
        else:
            dp[i][j]=(dp[i-1][j] + dp[i][j-1])%NUM 
print(dp[H-1][W-1]%NUM)

Submission status: Wrong Answer

Solution code:
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    h, w = ns()
    mat = [list(input()) for _ in range(h)]
    dp = [[0 for _ in range(w)] for __ in range(h)]
    dp[0][0] = 1

    def calc(x, y, val):
        if x >= w or y >= h:
            return
        if mat[y][x] == "#":
            return
        dp[y][x] += val
        return

    for y in range(h):
        for x in range(w):
            calc(x + 1, y, dp[y][x])
            calc(x, y + 1, dp[y][x])
    print(dp[h - 1][w - 1])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
H, W = map(int, input().split())
m = 10**9+7
index_lst = []
grid_0 = [0] * (W+1)
grid_0[1] = 1
for h in range(1, H+1):
  grid_1 = [0] * (W+1)
  for i, j in enumerate(input(), 1):
    if j == '.':
      grid_1[i-1] = (grid_0[i] + grid_1[i-1]) % m
    grid_0 = grid_1
    
print(grid_0[-1])

Submission status: Wrong Answer

Solution code:
r,c=map(int,input().split())
g=[]
for _ in range(r):
  g.append(input())
dp=[[0 for j in range(c)] for i in range(r)]
dp[0][0]=1
for i in range(r):
  for j in range(c):
    if g[i][j]=='.':
        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:
MOD = 1000000007
h,w=map(int,input().split())
graph=[]
for i in range(h):
  graph.append(list(input()))
#print(graph)
dp=[[0]*(w) for _ in range(h)]
dp[0][0]=1
for i in range(1,w):
  if graph[0][i]=='#':
    break
  dp[0][i]=1
for i in range(1,h):
  if graph[i][0]=='#':
    break
  dp[i][0]=1
for i in range(1,h):
  for j in range(1,w):
    #print(i-1,j-1)
    if(graph[i-1][j-1]=='#'):
      dp[i][j]=0
    else:
      dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD

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

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
graph=[]
for i in range(h):
  graph.append(list(input()))
#print(graph)
dp=[[0]*(w) for _ in range(h)]
dp[0][0]=1
for i in range(1,w):
  if graph[0][i]=='#':
    break
  dp[0][i]=1
for i in range(1,h):
  if graph[i][0]=='#':
    break
  dp[i][0]=1
for i in range(1,h):
  for j in range(1,w):
    #print(i-1,j-1)
    if(graph[i-1][j-1]=='#'):
      dp[i][j]=0
    else:
      dp[i][j]=(dp[i-1][j]+dp[i][j-1])%(1e9 + 7)

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

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
graph=[]
for i in range(h):
  graph.append(list(input()))
#print(graph)
dp=[[0]*(w) for _ in range(h)]
dp[0][0]=1
for i in range(1,w):
  dp[0][i]=dp[0][i-1] if graph[0][i]=='.' else 0
for i in range(1,h):
  dp[i][0]=dp[i-1][0] if graph[i][0]=='.' else 0
for i in range(1,h):
  for j in range(1,w):
    #print(i-1,j-1)
    if(graph[i-1][j-1]=='#'):
      dp[i][j]=0
    else:
      dp[i][j]=(dp[i-1][j]+dp[i][j-1])%(1e9 + 7)

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

Submission status: Wrong Answer

Solution code:
n , m = map(int , input().split())
dp = [[1 for j in range(m + 1)] for i in range(n + 1)]
for i in range(n + 1):
    dp.append([])
    for j in range(m + 1):
        dp[i].append(0)
arr = []
for i in range(n):
    arr.append(input())
dp[1][1] = 1
for i in range(1,n + 1):
    for j in range(1,m + 1):
        if arr[i - 1][j - 1] == '#' or (i == 1 and j == 1):
            continue
        dp[i][j] = dp[i - 1][j] + dp[i][j - 1]
print(dp[n][m] % 1000000007)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

from collections import defaultdict
from heapq import heappush, heappop
import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def debug(*x):
    print(*x)


def solve(H, W, data):
    "void()"
    score = [[0] * (W + 1) for i in range(H + 1)]
    score[0][1] = 1
    for y in range(1, H + 1):
        for x in range(1, W + 1):
            if data[y - 1][x - 1] == "#":
                score[y][x] = 0
            else:
                score[y][x] = (score[y - 1][x] + score[y][x - 1]) % MOD
    # print(score)
    return score[H][W]


def main():
    H, W = map(int, input().split())
    data = [input() for i in range(H)]
    print(solve(H, W, data))


T1 = """
3 4
...#
.#..
....
"""

T2 = """
5 5
..#..
.....
#...#
.....
..#..
"""

T3 = """
20 20
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
"""


def test_T3():
    """
    >>> as_input(T3)
    >>> main()
    345263555
    """


def test_T2():
    """
    >>> as_input(T2)
    >>> main()
    24
    """


def _test():
    """
    >>> as_input(T1)
    >>> main()
    3
    """
    import doctest
    doctest.testmod()


def as_input(s):
    "use in test, use given string as input file"
    import io
    global read, input
    f = io.StringIO(s.strip())
    input = f.readline
    read = f.read


USE_NUMBA = False
if (USE_NUMBA and sys.argv[-1] == 'ONLINE_JUDGE') or sys.argv[-1] == '-c':
    print("compiling")
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', solve.__doc__.strip().split()[0])(solve)
    cc.compile()
    exit()
else:
    input = sys.stdin.buffer.readline
    read = sys.stdin.buffer.read

    if (USE_NUMBA and sys.argv[-1] != '-p') or sys.argv[-1] == "--numba":
        # -p: pure python mode
        # if not -p, import compiled module
        from my_module import solve  # pylint: disable=all
    elif sys.argv[-1] == "-t":
        _test()
        sys.exit()
    elif sys.argv[-1] != '-p' and len(sys.argv) == 2:
        # input given as file
        input_as_file = open(sys.argv[1])
        input = input_as_file.buffer.readline
        read = input_as_file.buffer.read

    main()

Submission status: Wrong Answer

Solution code:
MOD = 10**9+7
H, W = map(int, input().split())
a = [input() for _ in range(H)]

dp = [[0] * W for _ in range(H)]
dp[0][0] = 1
for i in range(1, H):
    if a[i][0] != '#':
        dp[i][0] = dp[i-1][0]
    else:
        dp[i][0] = 0
for i in range(1, W):
    if a[0][i] != '#':
        dp[0][i] = dp[0][i-1]
    else:
        dp[0][i] = 0
        
for i in range(1, H):
    for j in range(1, W):
        if a[i][j] == '#':
            continue
        if a[i-1][j] != '#' and a[i][j-1] != '#':
            dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD
        elif a[i-1][j] != '#':
            dp[i][j] = dp[i-1][j]
        elif a[i][j-1] != '#':
            dp[i][j] = dp[i-1][j]
print(dp[H-1][W-1])

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
grid=[]
for _ in range(h):
    s=list(input())
    grid.append(s)

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 grid[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[h-1][w-1])

Submission status: Wrong Answer

Solution code:
mod=1e9+7
def addself(a):
    if(a<mod):
        return a
    else:
        return (a+mod)%mod
    
n,m=map(int,input().split())
x = []
dp = [[0 for i in range(m+1)] for j in range(n+1)]
dp[1][1] = 1
for i in range(n):
    l = list(input())
    x.append(l)
for i in range(1,n+1):
    for j in range(1,m+1):
        if i ==1 and j==1:
            continue
        if x[i-1][j-1]=='#':
            dp[i][j] = 0
        else:
            dp[i][j] = dp[i-1][j]+dp[i][j-1]

        dp[i][j]=addself(dp[i][j])
            
print(dp[-1][-1])

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
x = []
dp = [[0 for i in range(m+1)] for j in range(n+1)]
dp[1][1] = 1
for i in range(n):
    l = list(input())
    x.append(l)
for i in range(1,n+1):
    for j in range(1,m+1):
        if i ==1 and j==1:
            continue
        if x[i-1][j-1]=='#':
            dp[i][j] = 0
        else:
            dp[i][j] = dp[i-1][j]+dp[i][j-1]
print(dp[-1][-1])

Submission status: Wrong Answer

Solution code:
from collections import deque

H, W = map(int, input().split(" "))
m = [list(input().strip()) for _ in range(H)]
mod = 10**9 + 7

dp = [[-1] * W for _ in range(H)]
dp[H-1][W-1] = 1
que = deque()
que.append((H-2, W-1))
que.append((H-1, W-2))
visited = set([(H-1, W-1)])
while len(que) > 0:
    h, w = que.popleft()
    visited.add((h, w))
    steps = 0
    if h < H-1 and m[h+1][w] == "." and ((h+1, w) in visited):
        steps += dp[h+1][w]
    if w < W-1 and m[h][w+1] == "." and ((h, w+1) in visited):
        steps += dp[h][w+1]
    steps %= mod
    dp[h][w] = steps

    if not ((h-1, w) in visited) and h-1 >= 0 and m[h-1][w] == ".":
        que.append((h-1, w))
    if not ((h, w-1) in visited) and w-1 >= 0 and m[h][w-1] == ".":
        que.append((h, w-1))


print(dp[0][0])

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
mat=[]
for i in range(h):
    a=[i for i in list(input())]
    mat.append(a)
for i in range(w):
    if mat[0][i]=='.':
        mat[0][i]=1
    else:
        mat[0][i]=0
for i in range(1,h):
    for j in range(w):
        if mat[i][j]=='.':
            mat[i][j]=0
            mat[i][j]+=mat[i-1][j]
            if j-1>=0:
                mat[i][j]+=mat[i][j-1]
        else:
            mat[i][j]=0
print(mat[h-1][w-1]%1000000007)

Submission status: Wrong Answer

Solution code:


H, W = map(int, input().split())
arr = ['']*H
for i in range(H):
    arr[i] = input()
 
dp = [[0]*W for _ in range(H)]

# arr = [
# ['.','.'],
# ['#','.'],
# ['.','.'],
# ['.','#'],
# ['.','.']
# ]





flag= False
for h in range(H-1,-1,-1):
    #print(h,W-1)

    if arr[h][W-1]=='#':
        dp[h][W-1]=0
        flag =  True
    if flag:
        dp[h][W-1]=0
    else:
        dp[h][W-1]=1
print(dp)
    
flag = False
for w in range(W-1,-1,-1):
    #print(h,W-1)
    if arr[H-1][w]=='#':
        dp[H-1][w]=0
        flag =  True
    if flag:
        dp[H-1][w]=0
    else:
        dp[H-1][w]=1



MOD = 10**9+7

dp[H-1][W-1]=0

for row in range(H-1,0,-1):
    for col in range(W-1,0,-1):
        if arr[row-1][col-1]=='#':
            dp[row-1][col-1]=0
        elif dp[row][col-1] ==0 or dp[row-1][col]==0:
            dp[row-1][col-1] = max(dp[row][col-1],  dp[row-1][col])
            dp[row-1][col-1]%=MOD

        elif dp[row][col-1] > 0 and dp[row-1][col]>0:
            dp[row-1][col-1] = dp[row][col-1] +  dp[row-1][col]
            dp[row-1][col-1]%=MOD
        elif  dp[row][col-1] == 0 and dp[row-1][col] == 0:
            dp[row-1][col-1]==0


print(dp[0][0])

Submission status: Wrong Answer

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

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



flag= False
for h in range(H-1,-1,-1):
    print(h, W-1)
    if arr[h][W-1]=='#':

        dp[h][W-1]=-1
        flag =  True
    if flag:
        dp[h][W-1]=-1
    else:
        dp[h][W-1]=1
    
flag = False
for w in range(W-1,-1,-1):
    if arr[H-1][w]=='#':
        dp[H-1][w]=-1
        flag =  True
    if flag:
        dp[H-1][w]=-1
    else:
        dp[H-1][w]=1

MOD = 10**9+7


for row in range(H-1,0,-1):
    for col in range(W-1,0,-1):
        if arr[row-1][col-1]=='#':
            dp[row-1][col-1]=-1
        elif dp[row][col-1] ==-1 or dp[row-1][col]==-1:
            dp[row-1][col-1] = max(dp[row][col-1],  dp[row-1][col])
            dp[row-1][col-1]%=MOD

        elif dp[row][col-1] > -1 and dp[row-1][col]>-1:
            dp[row-1][col-1] = dp[row][col-1] +  dp[row-1][col]
            dp[row-1][col-1]%=MOD


print(dp[0][0])

Submission status: Wrong Answer

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

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



flag= False
for h in range(H-1,-1,-1):
    print(h, W-1)
    if arr[h][W-1]=='#':

        dp[h][W-1]=-1
        flag =  True
    if flag:
        dp[h][W-1]=-1
    else:
        dp[h][W-1]=1
    
flag = False
for w in range(W-1,-1,-1):
    if arr[H-1][w]=='#':
        dp[H-1][w]=-1
        flag =  True
    if flag:
        dp[H-1][w]=-1
    else:
        dp[H-1][w]=1



for row in range(H-1,0,-1):
    for col in range(W-1,0,-1):
        if arr[row-1][col-1]=='#':
            dp[row-1][col-1]=-1
        elif dp[row][col-1] ==-1 or dp[row-1][col]==-1:
            dp[row-1][col-1] = max(dp[row][col-1],  dp[row-1][col])
        elif dp[row][col-1] > -1 and dp[row-1][col]>-1:
             dp[row-1][col-1] = dp[row][col-1] +  dp[row-1][col]

print(dp[0][0]%(10**9+7))

Submission status: Wrong Answer

Solution code:
def solve(result,rows,cols):

    t={"#":1,".":0}
    dp=[[1]*cols for i in range(rows)]
    dp[0][0]=1
    for j in range(1,cols):
        dp[0][j]=dp[0][j-1]*(1-t[result[0][j]])
    for i in range(1,rows):
        dp[i][0]=dp[i-1][0]*(1-t[result[i][0]])
        
    for i in range(1,rows):
        for j in range(1,cols):
            if result[i][j]=="#":
                dp[i][j]=0
            else:
                dp[i][j]=dp[i-1][j]+dp[i][j-1]
            
            
    return dp[-1][-1]

        
    


value=[int(i) for i in input().split()]
rows,cols=value[0],value[1]
result=[]
for i in range(rows):
    t=input()
    result.append(t)
#result=[[str(i) for i in input().split()]for j in range(rows)]
print(solve(result,rows,cols))

Submission status: Wrong Answer

Solution code:
import sys
buf = sys.stdin.buffer

import numpy as np
MOD = 10 ** 9 + 7

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

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

print(grid)

MOD = 10 ** 9 + 7
dp = np.zeros(W, dtype = np.int64)
dp[0] = 1

for row in grid:
  print(row == b"#")
  wall = (row == b'#')
  # 上から落としてくる
  dp[wall] = 0
  # 左から右に
  np.cumsum(dp, out = dp)
  # 壁の補正
  sub = np.maximum.accumulate(dp * wall)
  dp -= sub
  dp %= MOD

answer = dp[-1]
print(answer)

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import collections
import numpy as np

rl = sys.stdin.readline

h, w = map(int, rl().split())

li = []
dh = [0, -1]
dw = [-1, 0]
dp = [[0] * w for _ in range(h)]
dp[0][0] = 1
for _ in range(h):
    li.append(rl().rstrip())
for i in range(h):
    for j in range(w):
        if li[i][j] == '#':
            continue
        a = 0
        for k in range(2):
            nh = i + dh[k]
            nw = j + dw[k]
            if nh < 0 or nw < 0:
                continue
            a += dp[nh][nw]
        if dp[i][j] == 0:
            dp[i][j] = a
print(dp[-1][-1])

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import collections
import numpy as np

rl = sys.stdin.readline

h, w = map(int, rl().split())

li = []
dh = [0, -1]
dw = [-1, 0]
dp = [[0] * w for _ in range(h)]
dp[0][0] = 1
for _ in range(h):
    li.append(rl().rstrip())
for i in range(h):
    for j in range(w):
        if li[i][j] == '#':
            continue
        a = 0
        for k in range(2):
            nh = i + dh[k]
            nw = j + dw[k]
            if nh < 0 or nw < 0:
                continue
            a += dp[nh][nw]
        if dp[i][j] == 0:
            dp[i][j] = a
print(dp)

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import collections
import numpy as np

rl = sys.stdin.readline

h, w = map(int, rl().split())

li = []
dh = [0, -1]
dw = [-1, 0]
for _ in range(h):
    lis = []
    for v in rl().rstrip():
        lis.append(1 if v == '.' else 0)
    li.append(lis)
if li[-1][-1]:
    li[-1][-1] = 0
for i in range(1, h):
    for j in range(1, w):
        if li[i][j] == 0:
            continue
        a = 0
        for k in range(2):
            nh = dh[k] + i
            nw = dw[k] + j
            a += li[nh][nw]
        li[i][j] = a

print((li[-1][-1]) % ((10**9) + 7))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import numpy as np

if __name__=='__main__':
    H,W = map(int,input().split())
    
    dp = np.array([0 for _ in range(W+1)])
    dp[0] = 1
    for i in range(H):
        line = input()
        tmp = dp.copy()
        for j in range(W):
            if(line[j]=='.'):
                tmp[j+1] = dp[j+1] + tmp[j]
            else:
                tmp[j+1] = dp[j+1]
                tmp[j] = 0


        dp[:] = tmp[:]
    print(dp[W-1]%(10**9+7))

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
from collections import deque
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

mod=10**9+7
h,w=mp()
dp=[[0]*w for i in range(h)]
dp[0][0]=1
for i in range(h):
    s=input()
    for k in range(w):
        if s[k]=="#":
            dp[i][k]=-1



for i in range(h-1):
    for k in range(w-1):
        if dp[i][k]!=-1:
            if dp[i][k+1]!=-1:
                dp[i][k+1]+=dp[i][k]
                dp[i][k+1]=dp[i][k+1]%mod
            if dp[i+1][k]!=-1:
                dp[i+1][k]+=dp[i][k]
                dp[i+1][k]=dp[i+1][k]%mod
        if dp[i][w-1]!=-1 and dp[i+1][w-1]!=-1:
            dp[i+1][w-1]+=dp[i][w-1]
            dp[i+1][w-1]=dp[i+1][w-1]%mod
    for k in range(w-1):
            if dp[h-1][k]!=-1 and dp[h-1][k+1]!=-1:
                dp[h-1][k+1]+=dp[h-1][k]
                dp[h-1][k+1]=dp[h-1][k+1]%mod



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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import numpy as np


def main():
    """ TLE """
    H, W = map(int, input().split())
    A = [list(list(input())) for _ in range(H)]
    dp = np.zeros((H + 1, W + 1), dtype='uint64')
    dp[0][0] = 1

    for i in range(H):
        for j in range(W):
            if A[i][j] == '#':
                continue
            dp[i, j + 1] += dp[i][j]
            dp[i + 1, j] += dp[i][j]
    print(int(dp[H-1, W-1] % 1000000007))


if __name__ == "__main__":
    main()