結果

問題 No.2708 Jewel holder
ユーザー 👑 tipstar0125tipstar0125
提出日時 2024-03-31 14:08:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 951 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 66,520 KB
最終ジャッジ日時 2024-03-31 14:08:14
合計ジャッジ時間 1,662 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 36 ms
53,460 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 34 ms
53,460 KB
testcase_06 AC 34 ms
53,460 KB
testcase_07 AC 35 ms
53,460 KB
testcase_08 AC 48 ms
59,504 KB
testcase_09 WA -
testcase_10 AC 43 ms
59,976 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 34 ms
53,460 KB
testcase_15 AC 48 ms
64,308 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

ans=0
for i in range(1<<(H+W-2)):
    n=i.bit_count()
    if n!=H-1:continue
    bit=i
    row=0
    col=0
    cnt=1
    ok=True
    for j in range(H+W-2):
        if (bit>>j)&1==0:
            if row+1>=H or A[row+1][col]=="#":
                ok=False
                break
            if A[row+1][col]=="x":
                if cnt==0:
                    ok=False
                    break
                cnt-=1
            if A[row+1][col]=="o":
                cnt+=1
            row+=1
        else:
            if col+1>=W or A[row][col+1]=="#":
                ok=False
                break
            if A[row][col+1]=="x":
                if cnt==0:
                    ok=False
                    break
                cnt-=1
            if A[row][col+1]=="o":
                cnt+=1
            col+=1
        # print(bin(bit),row,col,cnt)
    if ok:ans+=1
print(ans)

0