結果

問題 No.792 真理関数をつくろう
ユーザー menheraumbrellamenheraumbrella
提出日時 2019-02-22 21:53:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 842 bytes
コンパイル時間 114 ms
コンパイル使用メモリ 10,788 KB
実行使用メモリ 17,908 KB
最終ジャッジ日時 2023-08-16 18:23:28
合計ジャッジ時間 6,170 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
17,908 KB
testcase_01 AC 22 ms
8,464 KB
testcase_02 AC 16 ms
7,900 KB
testcase_03 AC 35 ms
8,628 KB
testcase_04 AC 16 ms
7,872 KB
testcase_05 AC 34 ms
8,512 KB
testcase_06 AC 1,236 ms
9,768 KB
testcase_07 AC 19 ms
8,300 KB
testcase_08 AC 16 ms
7,708 KB
testcase_09 AC 16 ms
7,704 KB
testcase_10 AC 16 ms
7,836 KB
testcase_11 AC 16 ms
7,896 KB
testcase_12 AC 16 ms
7,960 KB
testcase_13 AC 16 ms
7,844 KB
testcase_14 AC 16 ms
7,844 KB
testcase_15 AC 17 ms
7,944 KB
testcase_16 AC 157 ms
8,856 KB
testcase_17 AC 16 ms
7,836 KB
testcase_18 AC 16 ms
7,784 KB
testcase_19 AC 15 ms
7,780 KB
testcase_20 AC 39 ms
9,016 KB
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
Q = []
R = []

for i in range(2 ** N):
        *q, r = [int(n) for n in input().split()]
        Q.append(q)
        R.append(r)

ans = "A="

if all([r == 1 for r in R]):
        ans += "⊤"
elif all([r == 0 for r in R]):
        ans += "⊥"
else:
        for i in range(2 ** N):
                if R[i] == 0:
                        continue
                else:
                        ans += "("
                        for j in range(N):
                                if Q[i][j] == 1:
                                        ans += "P_{}".format(j+1)
                                else:
                                        ans += "¬P_{}".format(j+1)
                                ans += "∧"
                        ans = ans[:-1]
                        ans += ")∨"

        ans = ans[:-1]
print(ans)


0