結果

問題 No.1366 交換門松列・梅
ユーザー universatouniversato
提出日時 2021-01-29 21:47:16
言語 Ruby
(3.2.2)
結果
AC  
実行時間 83 ms / 1,000 ms
コード長 397 bytes
コンパイル時間 628 ms
コンパイル使用メモリ 11,260 KB
実行使用メモリ 15,364 KB
最終ジャッジ日時 2023-07-30 09:00:12
合計ジャッジ時間 2,820 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,300 KB
testcase_01 AC 83 ms
15,272 KB
testcase_02 AC 82 ms
15,040 KB
testcase_03 AC 81 ms
15,260 KB
testcase_04 AC 80 ms
15,364 KB
testcase_05 AC 79 ms
15,172 KB
testcase_06 AC 79 ms
15,264 KB
testcase_07 AC 80 ms
15,304 KB
testcase_08 AC 79 ms
15,296 KB
testcase_09 AC 80 ms
15,252 KB
testcase_10 AC 83 ms
15,252 KB
testcase_11 AC 81 ms
15,176 KB
testcase_12 AC 81 ms
15,068 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Array
  def kadomatsu?
    return nil unless size == 3
    return false unless uniq.size == 3
    
    self[1] == min || self[1] == max
  end
end

a = gets.to_s.split.map{ |e| e.to_i }
b = gets.to_s.split.map{ |e| e.to_i }

[0, 1, 2].product([0, 1, 2]) do |i, j|
  c = a.dup
  d = b.dup
  c[i], d[j] = d[j], c[i]
  if c.kadomatsu? && d.kadomatsu?
    puts "Yes"
    exit
  end
end

puts "No"
0