結果

問題 No.792 真理関数をつくろう
ユーザー miya145592miya145592
提出日時 2023-06-27 02:57:13
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 562 bytes
コンパイル時間 1,555 ms
コンパイル使用メモリ 86,468 KB
実行使用メモリ 80,688 KB
最終ジャッジ日時 2023-09-16 22:40:57
合計ジャッジ時間 5,008 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,164 KB
testcase_01 AC 100 ms
76,720 KB
testcase_02 AC 76 ms
71,476 KB
testcase_03 AC 109 ms
77,468 KB
testcase_04 AC 76 ms
71,348 KB
testcase_05 AC 107 ms
77,428 KB
testcase_06 AC 129 ms
78,792 KB
testcase_07 AC 85 ms
75,676 KB
testcase_08 AC 76 ms
71,356 KB
testcase_09 AC 77 ms
71,008 KB
testcase_10 AC 76 ms
71,176 KB
testcase_11 AC 75 ms
71,208 KB
testcase_12 AC 76 ms
71,280 KB
testcase_13 AC 77 ms
71,172 KB
testcase_14 AC 76 ms
71,056 KB
testcase_15 AC 79 ms
71,176 KB
testcase_16 AC 122 ms
78,164 KB
testcase_17 AC 77 ms
71,168 KB
testcase_18 AC 75 ms
71,480 KB
testcase_19 AC 76 ms
71,204 KB
testcase_20 AC 108 ms
77,984 KB
testcase_21 AC 132 ms
80,688 KB
testcase_22 AC 75 ms
71,316 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 75 ms
71,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

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