結果

問題 No.792 真理関数をつくろう
ユーザー maspymaspy
提出日時 2020-01-29 21:53:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 612 bytes
コンパイル時間 70 ms
コンパイル使用メモリ 10,980 KB
実行使用メモリ 11,696 KB
最終ジャッジ日時 2023-10-14 07:34:08
合計ジャッジ時間 1,962 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,788 KB
testcase_01 AC 19 ms
8,472 KB
testcase_02 AC 15 ms
7,964 KB
testcase_03 AC 21 ms
8,868 KB
testcase_04 AC 15 ms
7,844 KB
testcase_05 AC 21 ms
8,936 KB
testcase_06 AC 41 ms
10,540 KB
testcase_07 AC 16 ms
8,280 KB
testcase_08 AC 14 ms
7,912 KB
testcase_09 AC 15 ms
7,916 KB
testcase_10 AC 15 ms
7,988 KB
testcase_11 AC 15 ms
7,860 KB
testcase_12 AC 15 ms
7,912 KB
testcase_13 AC 15 ms
8,004 KB
testcase_14 AC 15 ms
7,856 KB
testcase_15 AC 16 ms
7,816 KB
testcase_16 AC 29 ms
9,336 KB
testcase_17 AC 15 ms
7,804 KB
testcase_18 AC 15 ms
7,952 KB
testcase_19 AC 15 ms
7,852 KB
testcase_20 AC 30 ms
9,828 KB
testcase_21 AC 56 ms
11,696 KB
testcase_22 AC 15 ms
7,860 KB
testcase_23 AC 14 ms
8,312 KB
testcase_24 AC 15 ms
8,248 KB
testcase_25 AC 15 ms
7,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
data = [list(map(int,readline().split())) for _ in range(1<<N)]

data

*Q,R = zip(*data)
*Q, = zip(*Q)

if all(x == 1 for x in R):
    print('A=⊤')
    exit()
if all(x == 0 for x in R):
    print('A=⊥')
    exit()

words = []
for q,r in zip(Q,R):
    if r == 0:
        continue
    word = '(' + '∧'.join(('' if x else '¬') + 'P_{}'.format(i) \
                            for i,x in enumerate(q,1)) + ')'
    words.append(word)

A = 'A=' + '∨'.join(words)

print(A)
0