結果
問題 | No.2708 Jewel holder |
ユーザー | OhnoHiroki |
提出日時 | 2024-03-31 13:50:46 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 40 ms / 2,000 ms |
コード長 | 1,616 bytes |
コンパイル時間 | 343 ms |
コンパイル使用メモリ | 82,368 KB |
実行使用メモリ | 52,904 KB |
最終ジャッジ日時 | 2024-09-30 18:29:33 |
合計ジャッジ時間 | 2,029 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 36 ms
52,096 KB |
testcase_01 | AC | 36 ms
52,352 KB |
testcase_02 | AC | 40 ms
52,608 KB |
testcase_03 | AC | 37 ms
52,736 KB |
testcase_04 | AC | 35 ms
52,096 KB |
testcase_05 | AC | 34 ms
52,736 KB |
testcase_06 | AC | 35 ms
52,096 KB |
testcase_07 | AC | 34 ms
52,608 KB |
testcase_08 | AC | 34 ms
52,352 KB |
testcase_09 | AC | 34 ms
52,352 KB |
testcase_10 | AC | 35 ms
52,224 KB |
testcase_11 | AC | 37 ms
52,352 KB |
testcase_12 | AC | 36 ms
52,608 KB |
testcase_13 | AC | 35 ms
52,352 KB |
testcase_14 | AC | 37 ms
52,096 KB |
testcase_15 | AC | 37 ms
52,804 KB |
testcase_16 | AC | 35 ms
52,608 KB |
testcase_17 | AC | 36 ms
52,904 KB |
testcase_18 | AC | 36 ms
52,352 KB |
testcase_19 | AC | 33 ms
52,352 KB |
ソースコード
H,W = map(int, input().split()) A = [input() for _ in range(H)] D = [[{} for _ in range(W)] for _ in range(H)] D[0][0][1] = 1 for n in range(H+W-2): i = 0 j = n-i while j >= 0: if (0<=i<H) and (0<=j<W): if (0<=i+1<H) and A[i+1][j] != "#": if A[i+1][j] == "o": for key in D[i][j]: if key+1 in D[i+1][j]: D[i+1][j][key+1] += D[i][j][key] else: D[i+1][j][key+1] = D[i][j][key] else: for key in D[i][j]: if key-1 < 0: continue if key-1 in D[i+1][j]: D[i+1][j][key-1] += D[i][j][key] else: D[i+1][j][key-1] = D[i][j][key] if (0<=j+1<W) and A[i][j+1] != "#": if A[i][j+1] == "o": for key in D[i][j]: if key+1 in D[i][j+1]: D[i][j+1][key+1] += D[i][j][key] else: D[i][j+1][key+1] = D[i][j][key] else: for key in D[i][j]: if key-1 < 0: continue if key-1 in D[i][j+1]: D[i][j+1][key-1] += D[i][j][key] else: D[i][j+1][key-1] = D[i][j][key] i += 1 j -= 1 print(sum(D[-1][-1].values()))