結果

問題 No.2708 Jewel holder
ユーザー Theta
提出日時 2024-04-10 15:41:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 783 bytes
コンパイル時間 927 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 75,784 KB
最終ジャッジ日時 2024-10-02 17:56:19
合計ジャッジ時間 1,682 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import combinations


def main():
    H, W = map(int, input().split())
    board = [list(input()) for _ in range(H)]
    ctr = 0
    for h_dir in combinations(range(H + W - 2), H - 1):
        current = [0, 0]
        jewel = 1
        for idx in range(H + W - 2):
            if idx in h_dir:
                current = [current[0] + 1, current[1]]
            else:
                current = [current[0], current[1] + 1]
            if board[current[0]][current[1]] == "#":
                break
            if board[current[0]][current[1]] == "o":
                jewel += 1
            else:
                jewel -= 1
                if jewel < 0:
                    break
        else:
            ctr += 1
    print(ctr)


if __name__ == "__main__":
    main()
0