結果

問題 No.2708 Jewel holder
コンテスト
ユーザー koncha
提出日時 2024-03-31 13:40:45
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
TLE  
実行時間 -
コード長 538 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 316 ms
コンパイル使用メモリ 84,992 KB
実行使用メモリ 86,272 KB
最終ジャッジ日時 2026-04-16 20:16:15
合計ジャッジ時間 4,452 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 TLE * 1 -- * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from itertools import permutations


H, W = map(int, input().split())
A = [input() for _ in range(H)]

answer = 0
perm = list(set(permutations("D"*(H-1)+"R"*(W-1), H+W-2)))
for pattern in perm:
    cnt = 1
    h, w = 0, 0
    for p in pattern:
        if p == "D":
            h += 1
        else:
            w += 1
        if A[h][w] == "#":
            break
        elif A[h][w] == "x":
            cnt -= 1
            if cnt < 0:
                break
        else:
            cnt += 1
    else:
        answer += 1

print(answer)
0