結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー 👑 timitimi
提出日時 2023-05-19 22:11:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,744 bytes
コンパイル時間 397 ms
コンパイル使用メモリ 82,372 KB
実行使用メモリ 146,148 KB
最終ジャッジ日時 2024-06-01 01:09:09
合計ジャッジ時間 32,415 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
52,224 KB
testcase_01 AC 45 ms
52,480 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 273 ms
97,648 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 308 ms
132,184 KB
testcase_19 WA -
testcase_20 AC 286 ms
146,100 KB
testcase_21 AC 295 ms
140,852 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 297 ms
128,904 KB
testcase_28 WA -
testcase_29 AC 301 ms
141,428 KB
testcase_30 WA -
testcase_31 AC 282 ms
146,068 KB
testcase_32 WA -
testcase_33 AC 265 ms
121,996 KB
testcase_34 AC 283 ms
119,416 KB
testcase_35 AC 274 ms
117,072 KB
testcase_36 WA -
testcase_37 AC 323 ms
133,620 KB
testcase_38 AC 520 ms
77,800 KB
testcase_39 AC 686 ms
79,568 KB
testcase_40 AC 236 ms
77,444 KB
testcase_41 AC 268 ms
78,956 KB
testcase_42 AC 238 ms
113,044 KB
testcase_43 AC 249 ms
113,824 KB
testcase_44 AC 246 ms
144,492 KB
testcase_45 AC 253 ms
144,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T=int(input())
for _ in range(T):
  N,M=map(int, input().split())
  A=list(map(int, input().split()))
  B=list(map(int, input().split()))
  D={}
  for a in A:
    D[a]=1
  for b in B:
    if b in D:
      D[b]=2
    else:
      D[b]=-1
  r,b,c=0,0,0
  R,B,C=[],[],[]
  for d in D:
    if D[d]==2:
      c+=1
      C.append(d)
    elif D[d]==1:
      r+=1
      R.append(d)
    else:
      b+=1 
      B.append(d)
  ans=[]
  if c==0:
    if r==0 or b==0:
      print('Yes')
      if r==0:
        for i in B:
          print('Blue',i)
      else:
        for i in R:
          print('Red',i)
    else:
      print('No')
  elif c%2==0:
    if b==0:
      print('Yes')
      for i in R:
        print('Red',i)
      for i in range(c//2):
        x,y=C[2*i],C[2*i+1]
        print('Red',x)
        print('Blue',x)
        print('Blue',y)
        print('Red',y)
    elif r==0:
      print('Yes')
      for i in B:
        print('Blue',i)
      for i in range(c//2):
        x,y=C[2*i],C[2*i+1]
        print('Blue',x)
        print('Red',x)
        print('Red',y)
        print('Blue',y)
    else:
      print('Yes')
      x=C[-1]
      
      R.append(x)
      B.append(x)
      for i in R:
        print('Red',i)
      for i in range((c-1)//2):
        x,y=C[2*i],C[2*i+1]
        print('Red',x)
        print('Blue',x)
        print('Blue',y)
        print('Red',y)
      x=C[-2]
      print('Red',x)
      print('Blue',x)
      for i in B:
        print('Blue',i)
  else:
    print('Yes')
    for i in R:
      print('Red',i)
    for i in range(c):
      if i%2==0:
        print('Red',C[i])
        print('Blue',C[i])
      else:
        print('Blue',C[i])
        print('Red',C[i])
    for i in B:
      print('Blue',i)
              
        
0