結果
問題 | No.792 真理関数をつくろう |
ユーザー |
|
提出日時 | 2022-04-10 22:08:59 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 104 ms / 2,000 ms |
コード長 | 720 bytes |
コンパイル時間 | 400 ms |
コンパイル使用メモリ | 82,424 KB |
実行使用メモリ | 79,084 KB |
最終ジャッジ日時 | 2024-12-14 11:53:57 |
合計ジャッジ時間 | 2,526 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 |
ソースコード
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))