結果

問題 No.792 真理関数をつくろう
ユーザー dango
提出日時 2023-06-24 17:51:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,839 ms / 2,000 ms
コード長 561 bytes
コンパイル時間 750 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 262,736 KB
最終ジャッジ日時 2024-07-01 20:49:45
合計ジャッジ時間 5,394 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = [list(map(int, input().split())) for _ in range(1 << n)]
all_true = True
all_false = True
ans = "A="
for i in range(1 << n):
    if a[i][n] == 1:
        all_false = False
        if len(ans) > 2:
            ans += "∨"
        ans += "("
        for j in range(n):
            if j > 0:
                ans += "∧"
            if a[i][j] == 0:
                ans += "¬"
            ans += "P_" + str(j+1)
        ans += ")"
    else:
        all_true = False
if all_true:
    ans = "A=⊤"
elif all_false:
    ans = "A=⊥"
print(ans)
0