結果

問題 No.2708 Jewel holder
ユーザー ButterflvButterflv
提出日時 2024-04-18 09:27:45
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 656 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 68,352 KB
最終ジャッジ日時 2024-04-18 09:27:48
合計ジャッジ時間 2,126 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
60,416 KB
testcase_01 AC 47 ms
60,928 KB
testcase_02 AC 46 ms
60,672 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 37 ms
52,864 KB
testcase_06 AC 37 ms
52,864 KB
testcase_07 AC 49 ms
62,720 KB
testcase_08 AC 64 ms
67,456 KB
testcase_09 AC 57 ms
65,792 KB
testcase_10 AC 59 ms
66,816 KB
testcase_11 AC 51 ms
63,744 KB
testcase_12 AC 49 ms
61,696 KB
testcase_13 AC 59 ms
66,944 KB
testcase_14 AC 56 ms
65,024 KB
testcase_15 AC 58 ms
66,784 KB
testcase_16 AC 54 ms
65,024 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

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(1, len(dp[0][0])):
  ans+=dp[H-1][W-1][n]
print(ans)

# print(dp)
0