結果

問題 No.2708 Jewel holder
ユーザー budoubudou
提出日時 2024-04-07 06:19:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 825 bytes
コンパイル時間 378 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 70,600 KB
最終ジャッジ日時 2024-04-07 06:19:41
合計ジャッジ時間 2,958 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
68,232 KB
testcase_01 AC 60 ms
68,232 KB
testcase_02 AC 60 ms
68,232 KB
testcase_03 AC 64 ms
68,232 KB
testcase_04 AC 61 ms
68,232 KB
testcase_05 AC 84 ms
68,232 KB
testcase_06 AC 61 ms
68,232 KB
testcase_07 AC 61 ms
68,232 KB
testcase_08 AC 62 ms
68,232 KB
testcase_09 AC 61 ms
68,232 KB
testcase_10 AC 61 ms
68,232 KB
testcase_11 AC 61 ms
68,232 KB
testcase_12 AC 61 ms
68,232 KB
testcase_13 AC 64 ms
68,232 KB
testcase_14 AC 60 ms
68,232 KB
testcase_15 AC 66 ms
68,488 KB
testcase_16 AC 62 ms
68,232 KB
testcase_17 AC 71 ms
70,596 KB
testcase_18 AC 69 ms
70,600 KB
testcase_19 AC 68 ms
70,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import typing
import sys
input = lambda: sys.stdin.readline().strip()
inf = 10**18
mod = 998244353

def solve():
  H, W = map(int, input().split())
  grid = []
  for _ in range(H):
    grid.append(input())
  dp = [[[0 for _ in range(H*W+1)] for _ in range(W)] for _ in range(H)]
  dp[0][0][1] = 1
  for h in range(H):
    for w in range(W):
      if grid[h][w] == 'x':
        for k in range(H*W):
          if h > 0:
            dp[h][w][k] += dp[h-1][w][k+1]
          if w > 0:
            dp[h][w][k] += dp[h][w-1][k+1]
      elif grid[h][w] == 'o':
        for k in range(1,H*W+1):
          if h > 0:
            dp[h][w][k] += dp[h-1][w][k-1]
          if w > 0:
            dp[h][w][k] += dp[h][w-1][k-1]  
      else:
        pass
  print(sum(dp[-1][-1]))
def main():
  t = 1
  for _ in range(t):
    solve()
main()
0