結果
| 問題 | No.2307 [Cherry 5 th Tune *] Cool 46 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-05-19 22:17:37 |
| 言語 | PyPy3 (8.0.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 202 ms / 2,000 ms |
| + 501µs | |
| コード長 | 1,279 bytes |
| 記録 | |
| コンパイル時間 | 65 ms |
| コンパイル使用メモリ | 83,400 KB |
| 実行使用メモリ | 133,972 KB |
| 最終ジャッジ日時 | 2026-10-05 10:23:50 |
| 合計ジャッジ時間 | 24,871 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 46 |
ソースコード
import sys
input = sys.stdin.readline
def main():
T = int(input())
for _ in range(T):
N, M = map(int, input().split())
A = set(map(int, input().split()))
B = set(map(int, input().split()))
pair = []
ans = []
while A:
n = A.pop()
if n in B:
pair.append(n)
B.discard(n)
else:
ans.append(f'Red {n}')
if not pair:
if M == 0:
print('Yes')
print(*ans, sep='\n')
elif N == 0:
print('Yes')
while B:
print(f'Blue {B.pop()}')
else:
print('No')
continue
n = pair.pop()
ans.append(f'Red {n}')
ans.append(f'Blue {n}')
while B:
ans.append(f'Blue {B.pop()}')
cur = 'Blue'
while pair:
n = pair.pop()
if cur == 'Blue':
ans.append(f'Blue {n}')
ans.append(f'Red {n}')
cur = 'Red'
else:
ans.append(f'Red {n}')
ans.append(f'Blue {n}')
cur = 'Blue'
print('Yes')
print(*ans, sep='\n')
main()