結果
問題 |
No.792 真理関数をつくろう
|
ユーザー |
👑 |
提出日時 | 2021-08-26 17:20:54 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 102 ms / 2,000 ms |
コード長 | 585 bytes |
コンパイル時間 | 171 ms |
コンパイル使用メモリ | 82,760 KB |
実行使用メモリ | 85,376 KB |
最終ジャッジ日時 | 2024-11-18 10:57:02 |
合計ジャッジ時間 | 2,683 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 |
ソースコード
n = int(input()) grid = [list(map(int, input().split())) for _ in range(1 << n)] ans = ["A="] se = set() for i in range(1 << n): if grid[i][-1] == 0: se.add(0) continue se.add(1) ans.append("(") for j in range(n): if grid[i][j] == 1: ans.append(f"P_{j + 1}") else: ans.append(f"¬P_{j + 1}") ans.append("∧") ans.pop() ans.append(")") ans.append("∨") ans.pop() if len(se) == 1: if 0 in se: print("A=⊥") else: print("A=⊤") else: print("".join(ans))