結果
問題 | No.2307 [Cherry 5 th Tune *] Cool 46 |
ユーザー | Shirotsume |
提出日時 | 2023-05-19 21:46:41 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,161 bytes |
コンパイル時間 | 440 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 181,972 KB |
最終ジャッジ日時 | 2024-12-21 02:12:43 |
合計ジャッジ時間 | 28,880 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 59 ms
61,056 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 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | AC | 337 ms
79,864 KB |
testcase_39 | WA | - |
testcase_40 | AC | 316 ms
82,320 KB |
testcase_41 | AC | 298 ms
79,788 KB |
testcase_42 | AC | 335 ms
145,268 KB |
testcase_43 | AC | 339 ms
145,020 KB |
testcase_44 | AC | 399 ms
181,972 KB |
testcase_45 | AC | 393 ms
178,900 KB |
ソースコード
import copy import sys from collections import deque, Counter input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 63 - 1 mod = 998244353 def solve(): n, m = mi() a = set(mi()) b = set(mi()) pair = [] for v in list(a): if v in b: pair.append(v) a.discard(v) b.discard(v) ans1 = [] cnt = 0 for v in pair: if cnt % 2 == 0: ans1.append(('Red', v)) ans1.append(('Blue', v)) else: ans1.append(('Blue', v)) ans1.append(('Red', v)) cnt += 1 ax = copy.copy(a) bx = copy.copy(b) ans3 = ans1[::] cnt = 0 while a or b: if b: ans1.append(('Blue', b.pop())) elif a: ans1.append(('Red', a.pop())) cnt += 1 cnt = 0 a = copy.copy(ax) b = copy.copy(bx) while a or b: if a: ans3.append(('Red', a.pop())) elif b: ans3.append(('Blue', b.pop())) cnt += 1 ans2 = [] cnt = 0 for v in pair: if cnt % 2 == 1: ans2.append(('Red', v)) ans2.append(('Blue', v)) else: ans2.append(('Blue', v)) ans2.append(('Red', v)) cnt += 1 a = copy.copy(ax) b = copy.copy(bx) ans4 = ans2[::] cnt = 0 while a or b: if a: ans2.append(('Red', a.pop())) elif b: ans2.append(('Blue', b.pop())) cnt += 1 a = copy.copy(ax) b = copy.copy(bx) cnt = 0 while a or b: if b: ans4.append(('Blue', b.pop())) elif a: ans4.append(('Red', a.pop())) cnt += 1 cnt1 = 0 for i in range(len(ans1) - 1): if ans1[i][0] != ans1[i + 1][0]: cnt1 += 1 if ans1[i][0] != ans1[i + 1][0] and ans1[i][1] != ans1[i + 1][1]: cnt1 -= inf cnt2 = 0 for i in range(len(ans2) - 1): if ans2[i][0] != ans2[i + 1][0]: cnt2 += 1 if ans2[i][0] != ans2[i + 1][0] and ans2[i][1] != ans2[i + 1][1]: cnt2 -= inf cnt3 = 0 for i in range(len(ans2) - 1): if ans3[i][0] != ans3[i + 1][0]: cnt3 += 1 if ans3[i][0] != ans3[i + 1][0] and ans3[i][1] != ans3[i + 1][1]: cnt3 -= inf cnt4 = 0 for i in range(len(ans2) - 1): if ans4[i][0] != ans4[i + 1][0]: cnt4 += 1 if ans3[i][0] != ans4[i + 1][0] and ans4[i][1] != ans4[i + 1][1]: cnt4 -= inf if max(cnt1, cnt2, cnt3, cnt4) < 0: print('No') return print('Yes') if max(cnt1, cnt2, cnt3, cnt4) == cnt1: for x, y in ans1: print(x, y) elif max(cnt1, cnt2, cnt3, cnt4) == cnt2: for x, y in ans2: print(x, y) elif max(cnt1, cnt2, cnt3, cnt4) == cnt3: for x, y in ans3: print(x, y) elif max(cnt1, cnt2, cnt3, cnt4) == cnt4: for x, y in ans4: print(x, y) for _ in range(ii()): solve()