結果

問題 No.792 真理関数をつくろう
ユーザー miya145592miya145592
提出日時 2023-06-27 02:58:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 562 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 86,944 KB
実行使用メモリ 80,468 KB
最終ジャッジ日時 2023-09-16 22:41:54
合計ジャッジ時間 3,319 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,428 KB
testcase_01 AC 83 ms
76,796 KB
testcase_02 AC 66 ms
71,176 KB
testcase_03 AC 94 ms
77,360 KB
testcase_04 AC 67 ms
71,356 KB
testcase_05 AC 93 ms
77,648 KB
testcase_06 AC 115 ms
78,988 KB
testcase_07 AC 74 ms
75,912 KB
testcase_08 AC 66 ms
71,172 KB
testcase_09 AC 66 ms
71,112 KB
testcase_10 AC 68 ms
71,196 KB
testcase_11 AC 67 ms
71,128 KB
testcase_12 AC 69 ms
71,388 KB
testcase_13 AC 68 ms
71,228 KB
testcase_14 AC 68 ms
71,288 KB
testcase_15 AC 67 ms
71,176 KB
testcase_16 AC 106 ms
78,172 KB
testcase_17 AC 67 ms
71,356 KB
testcase_18 AC 68 ms
71,128 KB
testcase_19 AC 66 ms
71,200 KB
testcase_20 AC 98 ms
77,896 KB
testcase_21 AC 115 ms
80,468 KB
testcase_22 AC 65 ms
71,228 KB
testcase_23 AC 66 ms
71,172 KB
testcase_24 AC 63 ms
71,204 KB
testcase_25 AC 65 ms
71,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
QR = [list(map(int, input().split())) for _ in range(2**N)]

AND = "∧"
OR = "∨"
NOT = "¬"
BOTTOM = "⊥"
TOP = "⊤"

s = 0
ans = []
for i in range(2**N):
    r = QR[i][-1]
    s += r
    if r==1:
        temp = []
        for j in range(N):
            if QR[i][j]==1:
                temp.append(f"P_{j+1}")
            else:
                temp.append(f"{NOT}P_{j+1}")
        ans.append("(" + AND.join(temp) + ")")

if s==0:
    print(f"A={BOTTOM}")
    exit()
elif s==2**N:
    print(f"A={TOP}")
    exit()

print("A=" + OR.join(ans))
0