結果
問題 |
No.2307 [Cherry 5 th Tune *] Cool 46
|
ユーザー |
![]() |
提出日時 | 2023-05-20 07:59:55 |
言語 | Ruby (3.4.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,192 bytes |
コンパイル時間 | 288 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 46,812 KB |
最終ジャッジ日時 | 2024-12-21 07:13:25 |
合計ジャッジ時間 | 45,321 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 WA * 25 |
コンパイルメッセージ
Syntax OK
ソースコード
T = gets.to_i T.times do n, m = gets.split.map(&:to_i) a = gets.split.map(&:to_i).sort b = gets.split.map(&:to_i).sort if n == 0 puts 'Yes' b.each do |x| puts "Blue #{x}" end elsif m == 0 puts 'Yes' a.each do |x| puts "Red #{x}" end else a_cnt = a.tally b_cnt = b.tally c = a & b c_cnt = c.tally if c.empty? puts 'No' else puts 'Yes' t = 0 ans = [] c.each do |x| cnt = [a_cnt[x], b_cnt[x]].min cnt.times do if t.even? ans << "Red #{x}" ans << "Blue #{x}" else ans << "Blue #{x}" ans << "Red #{x}" end t += 1 end end if t.even? a.each do |x| next if c_cnt[x] ans << "Red #{x}" end b.each do |x| next if c_cnt[x] ans.unshift("Blue #{x}") end else b.each do |x| next if c_cnt[x] ans << "Blue #{x}" end a.each do |x| next if c_cnt[x] ans.unshift("Red #{x}") end end puts ans end end end