結果

問題 No.792 真理関数をつくろう
ユーザー wonda_t_coffeewonda_t_coffee
提出日時 2020-02-15 22:24:14
言語 Ruby
(3.3.0)
結果
AC  
実行時間 171 ms / 2,000 ms
コード長 409 bytes
コンパイル時間 233 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 14,080 KB
最終ジャッジ日時 2024-04-16 03:19:40
合計ジャッジ時間 4,649 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
12,160 KB
testcase_01 AC 106 ms
12,544 KB
testcase_02 AC 103 ms
12,288 KB
testcase_03 AC 112 ms
12,672 KB
testcase_04 AC 97 ms
12,160 KB
testcase_05 AC 110 ms
12,416 KB
testcase_06 AC 148 ms
13,568 KB
testcase_07 AC 102 ms
12,160 KB
testcase_08 AC 95 ms
12,160 KB
testcase_09 AC 96 ms
12,160 KB
testcase_10 AC 102 ms
12,160 KB
testcase_11 AC 99 ms
12,288 KB
testcase_12 AC 96 ms
12,032 KB
testcase_13 AC 99 ms
12,032 KB
testcase_14 AC 98 ms
12,160 KB
testcase_15 AC 104 ms
12,160 KB
testcase_16 AC 124 ms
12,800 KB
testcase_17 AC 98 ms
12,032 KB
testcase_18 AC 101 ms
12,032 KB
testcase_19 AC 99 ms
12,032 KB
testcase_20 AC 125 ms
12,928 KB
testcase_21 AC 171 ms
14,080 KB
testcase_22 AC 101 ms
12,288 KB
testcase_23 AC 98 ms
12,160 KB
testcase_24 AC 98 ms
12,160 KB
testcase_25 AC 98 ms
12,160 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.chomp.to_i
q = []
r = [] * n
(1 << n).times do
  l = gets.chomp.split.map(&:to_i)
  r << l.pop
  q << l
end

if r.uniq.size == 1
  puts "A=" + (r[0] == 0 ? '⊥' : '⊤')
  exit
end

ans = []
r.each.with_index do |ri, i|
  next if ri == 0

  s = []
  q[i].each.with_index(1) do |qj, j|
    s << (qj == 0 ? '¬' : '') + "P_#{j}"
  end
  ans << "(" + s.join('∧') + ")"
end
puts "A=" + ans.join('∨')
0