結果

問題 No.2708 Jewel holder
ユーザー RYOH2718RYOH2718
提出日時 2024-03-31 14:02:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 932 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 75,556 KB
最終ジャッジ日時 2024-03-31 14:02:39
合計ジャッジ時間 2,116 ms
ジャッジサーバーID
(参考情報)
judge10 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 38 ms
53,460 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 42 ms
53,460 KB
testcase_04 AC 38 ms
53,460 KB
testcase_05 AC 38 ms
53,460 KB
testcase_06 AC 38 ms
53,460 KB
testcase_07 AC 45 ms
53,460 KB
testcase_08 AC 53 ms
64,472 KB
testcase_09 AC 46 ms
60,100 KB
testcase_10 AC 52 ms
64,320 KB
testcase_11 AC 66 ms
70,540 KB
testcase_12 AC 37 ms
53,460 KB
testcase_13 AC 54 ms
64,432 KB
testcase_14 AC 40 ms
53,460 KB
testcase_15 AC 59 ms
66,392 KB
testcase_16 AC 43 ms
59,724 KB
testcase_17 AC 94 ms
75,556 KB
testcase_18 AC 69 ms
70,548 KB
testcase_19 AC 58 ms
66,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 標準入力された値を整数に変換する
def INT():
    return int(input())


# 標準入力された複数の値を整数に変換する
def MI():
    return map(int, input().split())


# 標準入力された複数の値を整数のリストに変換する
def LI():
    return list(map(int, input().split()))


H, W = MI()
A = [list(input()) for _ in range(H)]

ans = 0
for bit in range(1 << (H + W - 2)):
    jewel = 1
    h, w = 0, 0
    is_ok = True
    for i in range(H + W - 2):
        if (bit >> i) & 1:
            h += 1
        else:
            w += 1

        if h >= H or w >= W:
            is_ok = False
            break
        if A[h][w] == "o":
            jewel += 1
        elif A[h][w] == "x":
            jewel -= 1
            if jewel < 0:
                is_ok = False
                break
        else:
            is_ok = False
            break

    if is_ok:
        ans += 1

print(ans)
0