結果

問題 No.792 真理関数をつくろう
ユーザー maimai
提出日時 2019-02-22 21:32:41
言語 Ruby
(3.3.0)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 363 bytes
コンパイル時間 506 ms
コンパイル使用メモリ 11,188 KB
実行使用メモリ 16,624 KB
最終ジャッジ日時 2023-08-16 18:14:25
合計ジャッジ時間 3,562 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,108 KB
testcase_01 AC 88 ms
15,440 KB
testcase_02 AC 83 ms
15,284 KB
testcase_03 AC 91 ms
15,396 KB
testcase_04 AC 83 ms
15,064 KB
testcase_05 AC 90 ms
15,572 KB
testcase_06 AC 114 ms
16,012 KB
testcase_07 AC 85 ms
15,196 KB
testcase_08 AC 82 ms
15,164 KB
testcase_09 AC 82 ms
15,032 KB
testcase_10 AC 83 ms
15,060 KB
testcase_11 AC 83 ms
15,304 KB
testcase_12 AC 83 ms
15,240 KB
testcase_13 AC 82 ms
15,160 KB
testcase_14 AC 82 ms
15,224 KB
testcase_15 AC 84 ms
15,164 KB
testcase_16 AC 97 ms
15,656 KB
testcase_17 AC 83 ms
15,064 KB
testcase_18 AC 81 ms
15,088 KB
testcase_19 AC 81 ms
15,304 KB
testcase_20 AC 97 ms
15,424 KB
testcase_21 AC 127 ms
16,624 KB
testcase_22 AC 81 ms
15,216 KB
testcase_23 AC 81 ms
15,096 KB
testcase_24 AC 82 ms
15,060 KB
testcase_25 AC 81 ms
15,108 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
m = 2**N

clauses = []

flgT = true
flgF = true

m.times do
    h = gets.split.map(&:to_i)
    f = h.pop
    flgT &= f == 1
    flgF &= f == 0
    next if f == 0
    clauses << "("+h.each_with_index.map{|e, i| e==1 ? "P_#{i+1}" : "¬P_#{i+1}"}*"∧"+")"
end

if flgF
    puts "A=⊥"
elsif flgT
    puts "A=⊤"
else
    puts "A="+clauses*"∨"
end
0