結果

問題 No.2708 Jewel holder
ユーザー ButterflvButterflv
提出日時 2024-04-18 09:28:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 653 bytes
コンパイル時間 363 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 67,968 KB
最終ジャッジ日時 2024-04-18 09:28:47
合計ジャッジ時間 2,348 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
60,288 KB
testcase_01 AC 52 ms
60,288 KB
testcase_02 AC 53 ms
60,416 KB
testcase_03 AC 52 ms
58,624 KB
testcase_04 AC 47 ms
58,496 KB
testcase_05 AC 43 ms
52,608 KB
testcase_06 AC 42 ms
52,608 KB
testcase_07 AC 57 ms
62,464 KB
testcase_08 AC 75 ms
67,200 KB
testcase_09 AC 66 ms
65,792 KB
testcase_10 AC 70 ms
67,072 KB
testcase_11 AC 61 ms
63,488 KB
testcase_12 AC 56 ms
61,824 KB
testcase_13 AC 69 ms
66,816 KB
testcase_14 AC 65 ms
64,896 KB
testcase_15 AC 76 ms
66,560 KB
testcase_16 AC 65 ms
64,640 KB
testcase_17 AC 73 ms
67,968 KB
testcase_18 AC 72 ms
67,072 KB
testcase_19 AC 73 ms
67,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H, W=map(int, input().split())
S=list(input() for i in range(H))

# dp[h][w][n] で h行w列で宝石をn個持っている場合の数
dp=[[[0 for k in range(109)] for j in range(W)] for i in range(H)]

dp[0][0][1]=1
ans=0
for h in range(H):
  for w in range(W):
    for n in range(109):
      for dh, dw in ((1,0),(0,1)):
        nh, nw=h+dh, w+dw
        if (nh<H and nw<W)==False: continue
        if S[nh][nw]=="o" and n+1<len(dp[nh][nw]):
          dp[nh][nw][n+1]+=dp[h][w][n]
        elif S[nh][nw]=="x":
          if n-1>=0:
          	dp[nh][nw][n-1]+=dp[h][w][n]

for n in range(len(dp[0][0])):
  ans+=dp[H-1][W-1][n]
print(ans)

# print(dp)
0