結果

問題 No.792 真理関数をつくろう
ユーザー kohei2019kohei2019
提出日時 2022-04-10 22:08:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 146 ms / 2,000 ms
コード長 720 bytes
コンパイル時間 1,055 ms
コンパイル使用メモリ 86,748 KB
実行使用メモリ 80,576 KB
最終ジャッジ日時 2023-08-21 03:40:57
合計ジャッジ時間 4,055 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,120 KB
testcase_01 AC 97 ms
76,456 KB
testcase_02 AC 76 ms
71,172 KB
testcase_03 AC 108 ms
77,992 KB
testcase_04 AC 73 ms
71,416 KB
testcase_05 AC 109 ms
77,820 KB
testcase_06 AC 146 ms
79,388 KB
testcase_07 AC 82 ms
76,056 KB
testcase_08 AC 78 ms
71,120 KB
testcase_09 AC 75 ms
71,176 KB
testcase_10 AC 73 ms
71,384 KB
testcase_11 AC 75 ms
71,328 KB
testcase_12 AC 74 ms
71,436 KB
testcase_13 AC 75 ms
71,308 KB
testcase_14 AC 77 ms
71,404 KB
testcase_15 AC 80 ms
75,164 KB
testcase_16 AC 124 ms
78,364 KB
testcase_17 AC 76 ms
71,240 KB
testcase_18 AC 73 ms
71,252 KB
testcase_19 AC 75 ms
71,244 KB
testcase_20 AC 110 ms
77,944 KB
testcase_21 AC 135 ms
80,576 KB
testcase_22 AC 76 ms
71,324 KB
testcase_23 AC 75 ms
71,512 KB
testcase_24 AC 75 ms
71,480 KB
testcase_25 AC 73 ms
71,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
lsR = []
lsQ = []
for i in range(2**N):
    ls = list(map(int,input().split()))
    Q = ls[:-1]
    R = ls[-1]
    lsQ.append(Q)
    lsR.append(R)
ans = ['A=']
if lsR.count(0)==0:
    print('A=⊤')
elif lsR.count(1)==0:
    print('A=⊥')
else:
    for i in range(2**N):
        l = []
        l.append('(')
        if lsR[i] == 1:
            for j in range(N):
                if lsQ[i][j] == 1:
                    l.append('P_{}'.format(j+1))
                else:
                    l.append('¬P_{}'.format(j+1))
                l.append('∧')
            l.pop()
            l.append(')')
            ans.append(''.join(l))
            ans.append('∨')
    ans.pop()
    print(''.join(ans))

0