結果

問題 No.2090 否定論理積と充足可能性
ユーザー NyohoNyoho
提出日時 2022-09-30 22:51:42
言語 Ruby
(3.3.0)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 544 bytes
コンパイル時間 426 ms
コンパイル使用メモリ 11,448 KB
実行使用メモリ 15,336 KB
最終ジャッジ日時 2023-08-24 16:26:49
合計ジャッジ時間 3,471 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,116 KB
testcase_01 AC 79 ms
15,336 KB
testcase_02 AC 80 ms
15,152 KB
testcase_03 AC 80 ms
15,040 KB
testcase_04 AC 81 ms
15,152 KB
testcase_05 AC 79 ms
15,176 KB
testcase_06 AC 80 ms
15,152 KB
testcase_07 AC 78 ms
15,300 KB
testcase_08 AC 81 ms
15,220 KB
testcase_09 AC 79 ms
15,312 KB
testcase_10 AC 79 ms
15,284 KB
testcase_11 AC 81 ms
15,080 KB
testcase_12 AC 80 ms
15,128 KB
testcase_13 AC 80 ms
15,044 KB
testcase_14 AC 79 ms
15,048 KB
testcase_15 AC 79 ms
15,144 KB
testcase_16 AC 80 ms
15,232 KB
testcase_17 AC 79 ms
15,168 KB
testcase_18 AC 80 ms
15,116 KB
testcase_19 AC 79 ms
15,188 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def detect(x)
  nand(nand(nand(x[0], x[1]), x[2]), nand(nand(x[3], x[4]), x[5]))
end

# 0 = true
# 1 = false
def nand(a, b)
  if a == 0 and b == 0
    1
  else
    0
  end
end

a = gets.split.map(&:to_i)
u = a.uniq
as = [0,1].repeated_permutation(u.size).to_a

result = 1
as.size.times.each do |i|
  if detect(a.map { |e| as[i][u.index(e)] }) == 0
    result = 0
    break
  end
end
as.size.times.each do |i|
  if detect(a.map { |e| as[i][u.index(e)] }) == 0
    result = 0
    break
  end
end

if result == 0
  puts 'YES'
else
  puts 'NO'
end
0