結果

問題 No.2708 Jewel holder
ユーザー ThetaTheta
提出日時 2024-04-10 15:41:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 783 bytes
コンパイル時間 345 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 76,032 KB
最終ジャッジ日時 2024-04-10 15:42:02
合計ジャッジ時間 1,803 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
52,224 KB
testcase_01 AC 35 ms
52,352 KB
testcase_02 AC 35 ms
52,352 KB
testcase_03 AC 33 ms
52,736 KB
testcase_04 AC 33 ms
52,224 KB
testcase_05 AC 33 ms
52,736 KB
testcase_06 AC 33 ms
52,224 KB
testcase_07 AC 33 ms
52,224 KB
testcase_08 AC 34 ms
56,832 KB
testcase_09 AC 34 ms
56,704 KB
testcase_10 AC 33 ms
52,224 KB
testcase_11 AC 40 ms
61,288 KB
testcase_12 AC 33 ms
52,352 KB
testcase_13 AC 40 ms
60,544 KB
testcase_14 AC 40 ms
57,056 KB
testcase_15 AC 48 ms
62,976 KB
testcase_16 AC 36 ms
52,224 KB
testcase_17 AC 67 ms
76,032 KB
testcase_18 AC 54 ms
71,552 KB
testcase_19 AC 51 ms
72,960 KB
権限があれば一括ダウンロードができます

ソースコード

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