結果

問題 No.2708 Jewel holder
ユーザー 👑 timitimi
提出日時 2024-03-31 13:47:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 625 bytes
コンパイル時間 217 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 64,336 KB
最終ジャッジ日時 2024-03-31 13:47:24
合計ジャッジ時間 1,784 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
55,608 KB
testcase_01 AC 43 ms
55,608 KB
testcase_02 AC 42 ms
55,608 KB
testcase_03 AC 40 ms
55,608 KB
testcase_04 AC 41 ms
55,608 KB
testcase_05 AC 40 ms
55,608 KB
testcase_06 AC 42 ms
55,608 KB
testcase_07 AC 41 ms
55,608 KB
testcase_08 AC 41 ms
55,608 KB
testcase_09 AC 41 ms
55,608 KB
testcase_10 AC 41 ms
55,608 KB
testcase_11 AC 42 ms
55,608 KB
testcase_12 AC 41 ms
55,608 KB
testcase_13 AC 41 ms
55,608 KB
testcase_14 AC 43 ms
55,608 KB
testcase_15 AC 41 ms
55,608 KB
testcase_16 AC 40 ms
55,608 KB
testcase_17 AC 49 ms
64,336 KB
testcase_18 AC 41 ms
55,608 KB
testcase_19 AC 42 ms
55,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W=map(int, input().split())
A=[]
for i in range(H):
  X=input()
  A.append(X)

from collections import deque
D={}
D[(0,0)]=[0]*21 
D[(0,0)][1]=1
dy,dx=[1,0],[0,1]
for i in range(H+W-2):
  DD={}
  for d in D:
    y,x=d 
    for i in range(2):
      ny,nx=y+dy[i],x+dx[i]
      if 0<=ny<H and 0<=nx<W and A[ny][nx]!='#':
        if (ny,nx) not in DD:
          DD[(ny,nx)]=[0]*21
        if A[ny][nx]=='o':
          for j in range(20):
            DD[(ny,nx)][j+1]+=D[(y,x)][j]
        else:
          for j in range(20):
            DD[(ny,nx)][j]+=D[(y,x)][j+1]
  D=DD 
ans=0
for d in D:
  ans+=sum(D[d])
print(ans)
    

0