結果

問題 No.1366 交換門松列・梅
ユーザー gemmarogemmaro
提出日時 2021-05-24 12:23:00
言語 Ruby
(3.3.0)
結果
AC  
実行時間 102 ms / 1,000 ms
コード長 435 bytes
コンパイル時間 49 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-04-17 10:36:06
合計ジャッジ時間 1,948 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
12,160 KB
testcase_01 AC 93 ms
12,160 KB
testcase_02 AC 89 ms
12,160 KB
testcase_03 AC 91 ms
12,288 KB
testcase_04 AC 91 ms
12,416 KB
testcase_05 AC 95 ms
12,288 KB
testcase_06 AC 92 ms
12,160 KB
testcase_07 AC 91 ms
12,288 KB
testcase_08 AC 92 ms
12,160 KB
testcase_09 AC 89 ms
12,160 KB
testcase_10 AC 91 ms
12,160 KB
testcase_11 AC 90 ms
12,160 KB
testcase_12 AC 92 ms
12,160 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# frozen_string_literal: true

def swap(a, b)
  [A.dup.tap { _1[a] = B[b] },
   B.dup.tap { _1[b] = A[a] }]
end

def kadomatsu?(seq)
  seq.uniq.size == seq.size && (seq.max == seq[1] || seq.min == seq[1])
end

def solve
  3.times.each do |a|
    3.times.each do |b|
      return 'Yes' if swap(a, b).all? { kadomatsu? _1 }
    end
  end

  'No'
end

A = gets.chomp.split.map { _1.to_i }
B = gets.chomp.split.map { _1.to_i }

puts solve
0