結果

問題 No.2708 Jewel holder
ユーザー けん
提出日時 2024-11-01 20:16:23
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 699 bytes
コンパイル時間 550 ms
コンパイル使用メモリ 81,972 KB
実行使用メモリ 67,308 KB
最終ジャッジ日時 2024-11-01 20:16:26
合計ジャッジ時間 2,688 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other RE * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)

from more_itertools import distinct_permutations

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

ans = 0

for E in distinct_permutations([0] * (H - 1) + [1] * (W - 1)):
    cnt = 1
    y, x = 0, 0
    flag = True
    for e in E:
        if e == 0:
            y += 1
        else:
            x += 1
        if A[y][x] == "o":
            cnt += 1
        if A[y][x] == "x":
            cnt -= 1
            if cnt < 0:
                flag = False
                break
        if A[y][x] == "#":
            flag = False
            break
        
    if not flag: continue
    ans += 1

print(ans)
0