結果
問題 | No.792 真理関数をつくろう |
ユーザー |
|
提出日時 | 2020-02-17 12:17:24 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 157 ms / 2,000 ms |
コード長 | 761 bytes |
コンパイル時間 | 191 ms |
コンパイル使用メモリ | 7,296 KB |
実行使用メモリ | 15,616 KB |
最終ジャッジ日時 | 2024-10-06 14:54:18 |
合計ジャッジ時間 | 3,772 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 |
コンパイルメッセージ
Syntax OK
ソースコード
# frozen_string_literal: trueAND = '∧'OR = '∨'NOT = '¬'BOT = '⊥'TOP = '⊤'def make_exp(prop, index)case propwhen 0"#{NOT}P_#{index + 1}"when 1"P_#{index + 1}"endend# ----------------------------------- exectable = []N = gets.to_i(2**N).times doinput = gets.chomp.split.map(&:to_i)qs = input[0..-2]r = input[-1]table << [qs, r]endputs('A=' + if table.map { |r| r[1] }.uniq.size == 1if table[0][1].zero?BOTelseTOPendelseEXPS = table.select { |r| r[1] == 1 }.map do |r|r[0].map.with_index { |q, i| make_exp(q, i) }.join(AND)endEXPS.map { |e| "(#{e})" }.join(OR)end)