結果

問題 No.792 真理関数をつくろう
ユーザー pasoconhoshii
提出日時 2019-02-23 10:30:31
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 722 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 13,056 KB
最終ジャッジ日時 2024-11-28 22:31:21
合計ジャッジ時間 2,408 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

# N,M = map(int, input().split())
N = int(input())
Q = []
R = []

for i in range(1<<N):
    q = list(map(int, input().split()))
    Q.append( q[:-1] )
    R.append( q[-1]  )
    
if all(x == 1 for x in R):
    print("A=⊤")
elif all(x == 0 for x in R):
    print("A=⊥")
else:
    # ans = "A="
    anslst = []
    for i in range(1<<N):
        if R[i] == 1:
            # tmp = "("
            tmp = []
            for j in range(len(Q[i])):
                if Q[i][j] == 1:
                    tmp.append("P_{}".format(j+1))
                else:
                    tmp.append("¬P_{}".format(j+1))
            tmpst = "(" + "∧".join(tmp) + ")"
            anslst.append(tmpst)
    print("A="+ "∨".join(anslst))


0